Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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