Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro: Loop over all groups?

Does anyone of you know how to loop over all groups using a macro?

Normally I would count the items in the array I've got through "getgroups" and do a "for...next...loop" over them, but somehow I can't figure out how to count the existing groups (cyclic and drilldown) in the document.The normal count-method doesn't seem to work here.

Thanks for your help in advance...

3 Replies
Not applicable
Author

Hi

a bit strange, also ubound/lbound do not work. maybe better solutions exist than this one



sub groupmembers()
grouparray=activedocument.getgroups
for i = 0 to 5
on error resume next
set gp=grouparray(i).GetProperties
if err <> 0 then
msgbox("err " & i)
exit for
end if
next
end sub


Regards

Jürg

giakoum
Partner - Master II
Partner - Master II

you could use a while not isnull statement instead of for...next

guentherfrahm
Partner - Contributor
Partner - Contributor

try this one:

-> gives you groups and containing fields

Sub Get_Groups()

    groups = ActiveDocument.GetGroups

    j=0

    For each item in groups

        set gp = groups(j).GetProperties

        set gd = groups(j).GetDescription

        set vars = gp.FieldDefs

        for i = 0 to vars.Count-1

            set fld = vars.Item(i)

            msgbox("Group: " & gd.Name & " - field " & i+1 & " is " & fld.Name)

        Next

        j=j+1

    next

End Sub