Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Userform Command Button

In a Userform, I have multiple command buttons. For example:

D1_Click
D2_Click

Depending on another event that occurs, I want to calculate in code the
button name that I will be triggering the click event and then trigger the
event.

For example Application.Run "D" & i & "_Click"

with i being the value of 1 or 2.

Application.Run doesn't appear to work in the Userform.

Thanks

Steve
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Userform Command Button

Maybe it's because most subroutines in a userform module
are "Private"??? Have you tried changing the "Private"
prefix to "Public" for the D?_Click subroutines?? Maybe
that might fix it......

Also, im not entirely sure if changing routines from Private
to Public is a good idea for userform subroutines. Maybe
you can place your D?_Click code in a normal module
instead???


"sarndt" wrote in message
...
In a Userform, I have multiple command buttons. For example:

D1_Click
D2_Click

Depending on another event that occurs, I want to calculate in code the
button name that I will be triggering the click event and then trigger the
event.

For example Application.Run "D" & i & "_Click"

with i being the value of 1 or 2.

Application.Run doesn't appear to work in the Userform.

Thanks

Steve


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Userform Command Button

I tried changing it to Public and that didn't work. And Application.Run only
appears to work with a macro.

"Robert Crandal" wrote:

Maybe it's because most subroutines in a userform module
are "Private"??? Have you tried changing the "Private"
prefix to "Public" for the D?_Click subroutines?? Maybe
that might fix it......

Also, im not entirely sure if changing routines from Private
to Public is a good idea for userform subroutines. Maybe
you can place your D?_Click code in a normal module
instead???


"sarndt" wrote in message
...
In a Userform, I have multiple command buttons. For example:

D1_Click
D2_Click

Depending on another event that occurs, I want to calculate in code the
button name that I will be triggering the click event and then trigger the
event.

For example Application.Run "D" & i & "_Click"

with i being the value of 1 or 2.

Application.Run doesn't appear to work in the Userform.

Thanks

Steve


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Userform Command Button

Use CallByName. E.g.,

Dim S As String
S = "CommandButton1_Click"
CallByName UserForm1, S, VbMethod

The CommandButton1_Click must be declared as Public.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com



On Fri, 26 Feb 2010 12:32:03 -0800, sarndt
wrote:

In a Userform, I have multiple command buttons. For example:

D1_Click
D2_Click

Depending on another event that occurs, I want to calculate in code the
button name that I will be triggering the click event and then trigger the
event.

For example Application.Run "D" & i & "_Click"

with i being the value of 1 or 2.

Application.Run doesn't appear to work in the Userform.

Thanks

Steve

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
Centralizing a command button on a userform Roger on Excel Excel Programming 8 December 20th 09 05:52 PM
print command from command button in userform causes double chart Mike Jamesson Excel Programming 5 August 11th 09 03:42 AM
BUG: print command from command button in userform causes double c Mike Jamesson Excel Programming 0 August 10th 09 04:19 PM
Userform Command Button not available until another command buttonhas been used [email protected] Excel Programming 4 September 4th 08 04:35 PM
Use Command Button from each Row to fill UserForm RyanH Excel Programming 0 September 20th 07 01:24 PM


All times are GMT +1. The time now is 08:10 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"