Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The code below is from John Walkenbach's site (j-walk.com)
It makes easy work of handling multiple UserForm Buttons with one subroutine. I've been trying to adapt it to work with multiple image controls on a WORKSHEET rather than a UserForm. Any advice will be much appreciated Class1 code: Public WithEvents ButtonGroup As CommandButton Private Sub ButtonGroup_Click() MsgBox "Hello from " & ButtonGroup.Name End Sub Module1 code: Dim Buttons() As New Class1 UserForm1 code: Private Sub OKButton_Click() Unload Me End Sub Sub ShowDialog() Dim ButtonCount As Integer Dim ctl As Control ' Create the Button objects ButtonCount = 0 For Each ctl In UserForm1.Controls If TypeName(ctl) = "CommandButton" Then If ctl.Name < "OKButton" Then 'Skip the OKButton ButtonCount = ButtonCount + 1 ReDim Preserve Buttons(1 To ButtonCount) Set Buttons(ButtonCount).ButtonGroup = ctl End If End If Next ctl UserForm1.Show End Sub -- David |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
CLASS MODULE & SIMPLE MODULE | Excel Discussion (Misc queries) | |||
Chart Class Module/follow on question to hyperlink post earlier. | Charts and Charting in Excel | |||
let and get in class module | Excel Programming | |||
Class Module | Excel Programming | |||
Variable from a sheet module in a class module in XL XP | Excel Programming |