G
Guest
I have a chartsheet with a combobox. I want to loop through the combobox that
has 15 items. However the following macro gives an error "1004". It loops
from item 1 to 2 to 4 to 7 to 11 before giving the error. What goes wrong?
Sub LoopThroughCombo()
Dim i As Integer
Dim j As Integer
ActiveChart.DropDowns(1).ListIndex = 1
i = 0
j = UBound(ActiveChart.DropDowns(1).List)
MsgBox "j = " & j
For i = 0 To j - 1
'CommandBars("Custom").Controls(1).List (4) <> "View News"
ActiveChart.DropDowns(1).ListIndex = ActiveChart.DropDowns(1).Value + i
'Charts(1).DropDowns(1).ListIndex = i + 1
MsgBox ActiveChart.DropDowns(1).Value & " - " &
ActiveChart.DropDowns(1).ListIndex
Next
' Call UpdateChart(ListIndex)
End Sub
has 15 items. However the following macro gives an error "1004". It loops
from item 1 to 2 to 4 to 7 to 11 before giving the error. What goes wrong?
Sub LoopThroughCombo()
Dim i As Integer
Dim j As Integer
ActiveChart.DropDowns(1).ListIndex = 1
i = 0
j = UBound(ActiveChart.DropDowns(1).List)
MsgBox "j = " & j
For i = 0 To j - 1
'CommandBars("Custom").Controls(1).List (4) <> "View News"
ActiveChart.DropDowns(1).ListIndex = ActiveChart.DropDowns(1).Value + i
'Charts(1).DropDowns(1).ListIndex = i + 1
MsgBox ActiveChart.DropDowns(1).Value & " - " &
ActiveChart.DropDowns(1).ListIndex
Next
' Call UpdateChart(ListIndex)
End Sub