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

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Nested For Loop Not Working

I'm having problems with a nested FOR loop. When I add the inner for loop, the macro errors out. If I comment out the inner for loop and simply set the first chartDimensions(0).NullSuppression = true, it works just fine.

Can someone let me know what is wrong with my inner for loop?

sub Suppress_NULL_Values  

 

          set button = ActiveDocument.getSheetObject("BU16")

          charts=ActiveDocument.ActiveSheet.GetGraphs

 

          if button.GetText = "Suppress Nulls" then

             

                    for i = lbound(charts) to ubound(charts) 'THIS FOR LOOP WORKS

                              'Suppress Nulls

                              set chartProperties = charts(i).GetProperties

                              set chartDimensions = chartProperties.Dimensions

 

                              for c = lbound(chartDimensions) to ubound(chartDimensions) 'THIS ONE CAUSES MACRO TO ERROR OUT

                                        chartDimensions(c).NullSuppression = true

                              next 

 

                              charts(i).SetProperties chartProperties

 

                    next

 

                    'Change button text

                    set buttText = button.GetProperties

                    buttText.Text.v = "Show Nulls"

                    button.SetProperties buttText

 

          else

... 'Rest of the code omitted for brevity

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

This works for me:

sub Test

          charts=ActiveDocument.ActiveSheet.GetGraphs

          for i = lbound(charts) to ubound(charts)

                    set chartProperties = charts(i).GetProperties

                    for c = 0 to chartDimensions.Count - 1

                                   chartDimensions(c).NullSuppression = true

                    next

                    charts(i).SetProperties chartProperties

            next

end sub


talk is cheap, supply exceeds demand

View solution in original post

1 Reply
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

This works for me:

sub Test

          charts=ActiveDocument.ActiveSheet.GetGraphs

          for i = lbound(charts) to ubound(charts)

                    set chartProperties = charts(i).GetProperties

                    for c = 0 to chartDimensions.Count - 1

                                   chartDimensions(c).NullSuppression = true

                    next

                    charts(i).SetProperties chartProperties

            next

end sub


talk is cheap, supply exceeds demand