Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default Control Number - A better way

I use something similar to this in a lot of userforms and was hoping that
there might be a better way.

Scenario.......
I want to pass the number of the CommandButton clicked to another sub.

How I do it now......
Private Sub CBClick()
' Do stuff here based on the BoxClicked Number
End Sub
Private Sub CommandButton1_Click()
BoxClicked = 1
CBClick
End Sub
Private Sub CommandButton2_Click()
BoxClicked = 2
CBClick
End Sub

' continued for another 97 Command Buttons

Private Sub CommandButton99_Click()
BoxClicked = 99
CBClick
End Sub

Is there a better way?????

Thanks,
John


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Control Number - A better way

As far as I know, you have to create a variable that can be stored on a
worksheet and then capture it in another sub from the worksheet. Or, make
public variable declarations up front and use those. There is no simple way
that I know of.


"John Wilson" wrote:

I use something similar to this in a lot of userforms and was hoping that
there might be a better way.

Scenario.......
I want to pass the number of the CommandButton clicked to another sub.

How I do it now......
Private Sub CBClick()
' Do stuff here based on the BoxClicked Number
End Sub
Private Sub CommandButton1_Click()
BoxClicked = 1
CBClick
End Sub
Private Sub CommandButton2_Click()
BoxClicked = 2
CBClick
End Sub

' continued for another 97 Command Buttons

Private Sub CommandButton99_Click()
BoxClicked = 99
CBClick
End Sub

Is there a better way?????

Thanks,
John



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Control Number - A better way

http://j-walk.com/ss/excel/tips/tip44.htm

RBS


"John Wilson" wrote in message
...
I use something similar to this in a lot of userforms and was hoping that
there might be a better way.

Scenario.......
I want to pass the number of the CommandButton clicked to another sub.

How I do it now......
Private Sub CBClick()
' Do stuff here based on the BoxClicked Number
End Sub
Private Sub CommandButton1_Click()
BoxClicked = 1
CBClick
End Sub
Private Sub CommandButton2_Click()
BoxClicked = 2
CBClick
End Sub

' continued for another 97 Command Buttons

Private Sub CommandButton99_Click()
BoxClicked = 99
CBClick
End Sub

Is there a better way?????

Thanks,
John


Reply
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
How to make control number in cell Jon Excel Discussion (Misc queries) 1 July 21st 07 09:13 PM
Number of UserForm Control Objects IT_roofer Excel Programming 14 June 12th 07 08:36 PM
Auto control number Freshman Excel Worksheet Functions 1 September 22nd 06 12:40 PM
Control Displays Number Instead of Date Chaplain Doug Excel Programming 1 February 27th 06 06:08 PM
document control number Mark Barnard[_2_] Excel Programming 1 May 2nd 05 02:44 PM


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

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

About Us

"It's about Microsoft Excel"