LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Class module question

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CLASS MODULE & SIMPLE MODULE FARAZ QURESHI Excel Discussion (Misc queries) 1 September 7th 07 09:32 AM
Chart Class Module/follow on question to hyperlink post earlier. Rominall Charts and Charting in Excel 2 March 7th 07 02:43 AM
let and get in class module Doug Glancy Excel Programming 3 June 30th 04 02:30 PM
Class Module Todd Huttenstine Excel Programming 2 May 21st 04 11:17 PM
Variable from a sheet module in a class module in XL XP hglamy[_2_] Excel Programming 2 October 14th 03 05:48 PM


All times are GMT +1. The time now is 05:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"