Hi,
I'm looking for a way to specify a parameter for an OnAction-setting of a vba-excel-drawn button.
The following piece of (non-working) code should illustrate the concept:
</PRE>
<!-- END TEMPLATE: bbcode_code -->Any suggestions are welcome.
Thank you in advance.
I'm looking for a way to specify a parameter for an OnAction-setting of a vba-excel-drawn button.
The following piece of (non-working) code should illustrate the concept:
Code:
[COLOR=#000000]<STYLE>.alt2 font {font: 11px monospace !important;color: #333 !important;}</STYLE>[/COLOR]
[COLOR=#000000][FONT=Arial][SIZE=2]Sub dumpArray(inputArray() As Double)[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial][SIZE=2] Set datasheet = outputWorkbook.Sheets("Results")[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial][SIZE=2] For i = 0 To UBound(inputArray)[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial][SIZE=2] datasheet.cells(i,1) = inputArray(i)[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial][SIZE=2] If inputArray(i) >= 25 Then[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial][SIZE=2] addButton(i)[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial][SIZE=2] End If[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial][SIZE=2] Next i[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial][SIZE=2]End Sub[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial][SIZE=2]Sub addButton(n As Integer)[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial][SIZE=2] Set datasheet = outputWorkbook.Sheets("Results")[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial][SIZE=2] Set s = datasheet.Buttons.Add(datasheet.Cells(n,2).Left, _ [/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial][SIZE=2] datasheet.Cells(n,2).Top, 100, 12.75)[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial][SIZE=2] s.OnAction = DoSomething(n)[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial][SIZE=2]End Sub[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial][SIZE=2]Sub DoSomething(n As Integer)[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial][SIZE=2] MsgBox "You want to do something with the value of inputArray(n)"[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Arial][SIZE=2]End Sub[/SIZE][/FONT][/COLOR]
</PRE>
<!-- END TEMPLATE: bbcode_code -->Any suggestions are welcome.
Thank you in advance.