Class module question

G

Guest

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
 
G

Guest

Peter,
Yes, it was me, I am now using .topLeftCell to get the contents of cells
local to the each image control (I've got about 40 on each sheet). The local
cell info then becomes criteria for database query(s). The query feeds a
chart and the chart is displayed in a userform; ie the user clicks an image
control and gets the relevant to the location of the image info presented on
a chart. I've still got a bit to do but it's shaping up great thanks to the
help from yourself and others like you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top