Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default UserForm - Setting focus to a CommandButton based on a Cell's contents

I have another UserForm Question. I have a series of CommandButtons that
are named, starting at M1 through M76. When I show the UserForm, I know I
can set the focus to CommandButton "M11" by using the following.

UserForm3.M11.SetFocus

Is there a way I can set the focus in this same way except "11" would
actually be the contents of a cell which determines which command button the
focus should be set for?
Let's say A1 contains the number "11".

I know the code below doesn't work, but this is the idea.
UserForm3."M" & Range("A1").value.SetFocus

Can this be done?
Thanks,
Paul


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default UserForm - Setting focus to a CommandButton based on a Cell's contents

Try using:

UserForm3.Controls("M" & Range("A1").Value).SetFocus

--
Regards,

Juan Pablo González

"PCLIVE" wrote in message
...
I have another UserForm Question. I have a series of CommandButtons that
are named, starting at M1 through M76. When I show the UserForm, I know I
can set the focus to CommandButton "M11" by using the following.

UserForm3.M11.SetFocus

Is there a way I can set the focus in this same way except "11" would
actually be the contents of a cell which determines which command button
the focus should be set for?
Let's say A1 contains the number "11".

I know the code below doesn't work, but this is the idea.
UserForm3."M" & Range("A1").value.SetFocus

Can this be done?
Thanks,
Paul



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default UserForm - Setting focus to a CommandButton based on a Cell's contents

Well I thought I tried your suggestion, but I guess it what I tried was
slightly different. Anyway your suggestion works perfect.

Thanks,
Paul

"Juan Pablo González" wrote in message
...
Try using:

UserForm3.Controls("M" & Range("A1").Value).SetFocus

--
Regards,

Juan Pablo González

"PCLIVE" wrote in message
...
I have another UserForm Question. I have a series of CommandButtons that
are named, starting at M1 through M76. When I show the UserForm, I know I
can set the focus to CommandButton "M11" by using the following.

UserForm3.M11.SetFocus

Is there a way I can set the focus in this same way except "11" would
actually be the contents of a cell which determines which command button
the focus should be set for?
Let's say A1 contains the number "11".

I know the code below doesn't work, but this is the idea.
UserForm3."M" & Range("A1").value.SetFocus

Can this be done?
Thanks,
Paul





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
Conditional formatting based on a cell's contents Budget Programmer Excel Discussion (Misc queries) 3 February 23rd 09 10:35 PM
Take Focus Off of CommandButton When Exiting UserForm Minitman[_5_] Excel Programming 2 November 17th 06 08:18 PM
How do I make a cell's contents equal to another cell's contents with macro program? mgmcdevitt[_10_] Excel Programming 2 September 15th 05 09:44 PM
Can I select a range based on the cell's contents? [email protected] Excel Programming 1 July 29th 05 11:08 AM
CommandButton - Userform Marcia3641 Excel Discussion (Misc queries) 2 July 21st 05 06:39 PM


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