PC Review


Reply
Thread Tools Rate Thread

Control Number - A better way

 
 
John Wilson
Guest
Posts: n/a
 
      20th Jan 2008
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 With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      21st Jan 2008
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
>
>
>

 
Reply With Quote
 
RB Smissaert
Guest
Posts: n/a
 
      21st Jan 2008
http://j-walk.com/ss/excel/tips/tip44.htm

RBS


"John Wilson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ato generated control number MyMel Microsoft Access Forms 1 12th Dec 2009 07:32 PM
Control number of BackgroundWorkers? Paul Hatcher Microsoft C# .NET 0 17th Nov 2008 10:20 AM
Auto control number =?Utf-8?B?RnJlc2htYW4=?= Microsoft Excel Worksheet Functions 1 22nd Sep 2006 12:40 PM
document control number =?Utf-8?B?TWFyayBCYXJuYXJk?= Microsoft Excel Programming 1 2nd May 2005 02:44 PM
max. number of Web Control binding? Billy Bob Microsoft ASP .NET 0 20th Aug 2003 03:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:23 PM.