ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Naming UserForm CommandButtons using VBA (https://www.excelbanter.com/excel-programming/382225-naming-userform-commandbuttons-using-vba.html)

PCLIVE

Naming UserForm CommandButtons using VBA
 
This is slightly different than something I asked yesterday. Unfortunately,
applying yesterday's solution method does not work for this.
I'm trying to name a series of command buttons on a UserForm. Can you use
code to name commandbuttons on a Userform? This is what I got which doesn't
work.


For i = 1 To 37
c = 38

UserForm3.Controls("CommandButton" & i).Name = "M" & c

c = c + 1
Next i


Thanks,
Paul



Bob Phillips

Naming UserForm CommandButtons using VBA
 
No you didn't, you asked how to set the caption. You cannot set the name
property at runtime, just like the error message told you.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"PCLIVE" wrote in message
...
This is slightly different than something I asked yesterday.
Unfortunately, applying yesterday's solution method does not work for
this.
I'm trying to name a series of command buttons on a UserForm. Can you use
code to name commandbuttons on a Userform? This is what I got which
doesn't work.


For i = 1 To 37
c = 38

UserForm3.Controls("CommandButton" & i).Name = "M" & c

c = c + 1
Next i


Thanks,
Paul





PCLIVE

Naming UserForm CommandButtons using VBA
 
Thanks Bob,

I wasn't saying that this was the same question, which as you pointed out
was dealing with setting the Caption properties. Your suggested solution
yesterday was dead-on and helped me accomplish exactly what I wanted.. But
I trying something different today, but still dealing with the UserForm
CommandButton Properties. Anyway, I had a feeling that this one couldn't be
done.

As always, thanks for your help.
Paul

"Bob Phillips" wrote in message
...
No you didn't, you asked how to set the caption. You cannot set the name
property at runtime, just like the error message told you.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"PCLIVE" wrote in message
...
This is slightly different than something I asked yesterday.
Unfortunately, applying yesterday's solution method does not work for
this.
I'm trying to name a series of command buttons on a UserForm. Can you
use code to name commandbuttons on a Userform? This is what I got which
doesn't work.


For i = 1 To 37
c = 38

UserForm3.Controls("CommandButton" & i).Name = "M" & c

c = c + 1
Next i


Thanks,
Paul








All times are GMT +1. The time now is 05:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com