Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Not applicable

Macro - Loop Through Table

I need a sample macro that loops thorugh a table and reads out some values.  I can't find one.  

1 Solution

Accepted Solutions
Highlighted
flipside
Valued Contributor II

Macro - Loop Through Table

You just need to specify the column index (starting at zero for column 1) so looping through values in the first column would need...

          set cell = TableBox.GetCell(RowIter,0)

flipside

6 Replies
flipside
Valued Contributor II

Macro - Loop Through Table

Hi,

From API Guide.qvw ...

set TableBox = ActiveDocument.GetSheetObject( "TB01" )

for RowIter = 0 to TableBox.GetRowCount-1

    for ColIter =0 to TableBox.GetColumnCount-1

        set cell = TableBox.GetCell(RowIter,ColIter)

        msgbox(cell.Text)

    next

next

flipside

Not applicable

Macro - Loop Through Table

Hi flipside

Where in the API did you get this? The Automation Examples sheet? If so, what search did you do on member?

flipside
Valued Contributor II

Macro - Loop Through Table

Hi Ian,

I'm working in QV10 and got it from ...

Class = TableBox

Member = GetCell

...  showing as introduced in 6.0x.

flipside

Not applicable

Macro - Loop Through Table

If I don't want to loop through each column but just get a value from one column how would i do that? 

set TableBox = ActiveDocument.GetSheetObject( "tb_emails_to_send" )

    for RowIter = 0 to TableBox.GetRowCount-1   

        set cell = ?

        msgbox(cell.Text)   

    next

Not applicable

Macro - Loop Through Table

This code moves from column to column and row to row and keepings counting. It gets the value in the 16th spot in the loop and puts into the variable vValue and exits the sub routine.

hths,

Stephen

sub ParetoCountInvValue1

vCounter1 = 0

vCounter2 = 0

set table = ActiveDocument.GetSheetObject( "CH01" )

for RowIter = 0 to table.GetRowCount-1

for ColIter =0 to table.GetColumnCount-1

set cell = table.GetCell(RowIter,ColIter)

vCounter1 = vCounter1 + 1

if vCounter1 = 16 then

'msgbox ColIter

'msgbox(cell.Text)

set v = ActiveDocument.Variables("vValue")

v.SetContent cell.Text,true

exit sub

else

end if

next

next

end sub

Highlighted
flipside
Valued Contributor II

Macro - Loop Through Table

You just need to specify the column index (starting at zero for column 1) so looping through values in the first column would need...

          set cell = TableBox.GetCell(RowIter,0)

flipside

Community Browser