This surely isn't the first time someone is asking about this, but after searching for a solution for 4 hours, I think it's time to ask...
Simplistically I'm supposed to do a group of commandbuttons (50-500, amount varies), all of withch should be assigned to a systematically different kind of macro (every button shows a different chart). I've tried to pass a argument through the OnAction- command, but it just doesn't work. I've tried a code like this:
Sub FormsButton_Add()
For i = 1 To 10 '//I'm trying first with 10 buttons
ActiveSheet.Buttons.Add(150, 50 + 50 * i, 50, 50).Select
Sheet1.Shapes(i).OnAction = " ' macro1(" & i & ") ' "
Next i
End Sub
Public Sub macro1(i As Integer)
'code for showing chart number (i)
End Sub
Problem is, that Excel doesn't find the macro1, because I'm messing with the arguments. Without arguments everything goes.
I'm having xl2000 with VBA 6.0
Simplistically I'm supposed to do a group of commandbuttons (50-500, amount varies), all of withch should be assigned to a systematically different kind of macro (every button shows a different chart). I've tried to pass a argument through the OnAction- command, but it just doesn't work. I've tried a code like this:
Sub FormsButton_Add()
For i = 1 To 10 '//I'm trying first with 10 buttons
ActiveSheet.Buttons.Add(150, 50 + 50 * i, 50, 50).Select
Sheet1.Shapes(i).OnAction = " ' macro1(" & i & ") ' "
Next i
End Sub
Public Sub macro1(i As Integer)
'code for showing chart number (i)
End Sub
Problem is, that Excel doesn't find the macro1, because I'm messing with the arguments. Without arguments everything goes.
I'm having xl2000 with VBA 6.0