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 |
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 |
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 |
All times are GMT +1. The time now is 02:29 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com