orangefury90
New Member
- Joined
- Sep 21, 2013
- Messages
- 11
Hello,
This is my first post and I am glad to help / have some of my questions answered concerning Excel and VBA.
Anyway, my problem is that I have a userform called "update_log_form" and I have a bunch of buttons where for each button I want to change the captions.
GOAL: easily change button captions.
So far, I have changed the names of each commandbutton to "R1C1", "R1C2" etc.
My code looks like this right now:
'CHANGE BUTTON NAMES
I also want to add other things such as if the button is hidden or not using .visible = true or .visible = false but I see this taking a long, long time.
If I have all the information I need already, is there any code which could easily transfer this information to each button with a for loop and an array?
I am thinking something like the code below could help (with 24 being the total number of buttons and "0 to 2" being 3 possible slots of information concerning each button. However, I can't seem to get the red code below to reference the buttons I want (or any button).
Dim button_array(0 To 24, 0 To 2) as string
'Update button captions with information from array
for i = 1 to 5
Hope somebody can help and Thanks in advance!!!
This is my first post and I am glad to help / have some of my questions answered concerning Excel and VBA.
Anyway, my problem is that I have a userform called "update_log_form" and I have a bunch of buttons where for each button I want to change the captions.
GOAL: easily change button captions.

So far, I have changed the names of each commandbutton to "R1C1", "R1C2" etc.
My code looks like this right now:
'CHANGE BUTTON NAMES
update_log_form.R1C1.Caption = 1
update_log_form.R1C2.Caption = 2
update_log_form.R1C3.Caption = 3
update_log_form.R1C4.Caption = 4
update_log_form.R1C5.Caption = 5
update_log_form.R2C1.Caption = 6
update_log_form.R2C2.Caption = 7
update_log_form.R2C3.Caption = 8
update_log_form.R2C4.Caption = 9
update_log_form.R2C5.Caption = 10
' ... etc
' ... etc
I also want to add other things such as if the button is hidden or not using .visible = true or .visible = false but I see this taking a long, long time.
If I have all the information I need already, is there any code which could easily transfer this information to each button with a for loop and an array?
I am thinking something like the code below could help (with 24 being the total number of buttons and "0 to 2" being 3 possible slots of information concerning each button. However, I can't seem to get the red code below to reference the buttons I want (or any button).
Dim button_array(0 To 24, 0 To 2) as string
'Update button captions with information from array
for i = 1 to 5
for j = 1 to 5
update_log_form.R(i)C(j).caption = button_array(i,0)
next j
next iHope somebody can help and Thanks in advance!!!