Using string value a command button name

Errdickasin

New member
Joined
Oct 9, 2019
Messages
3
Reaction score
0
Points
0
Excel Version(s)
latest
I pass the name of a command button to a string variable, then do several subroutines. After finishing the subroutines I want to put a value back to that particular command button. What is the command so that it will recognize the string as a command button? Use of Function will not work here.
 
Welcome to the forum!

What is your code? Is the command button a form control or activex control?

Strings are not command buttons so I don't know what you mean by:
What is the command so that it will recognize the string as a command button?
 
I pass the name of a command button to a string variable, then do several subroutines. After finishing the subroutines I want to put a value back to that particular command button. What is the command so that it will recognize the string as a command button? Use of Function will not work here.
I found what I was looking for by going to a program I had written several years ago. Thanks for the reply, I was starting to lose hope.
Using VBA, here was my situation:
I have several command buttons on a form. I use them so the end user is limited to the amount of wrong answers they can enter.
For clarity, let's say I have named that button "Peaches"
When the end user presses that button, the string "Peaches" gets passed to the tag value of a label (let's call it "Bushels").
Lots of other actions, subroutines, and the like now happen, but eventually, a value (let's say 42) is to be put back to the Peaches command button tag value. The only way I know that it is supposed to go to the Peaches command button as opposed to some other button, is that it is noted in Bushels.Tag
Bushels.Tag = 42 'this code will only change the value of Bushels.Tag.
Controls(Bushels.Tag).Tag = 42 'The word "Controls" was what I was looking for. This will now take the string that is in Bushels.Tag and use it as if it is the command button Peaches, resulting in 42 being placed in Peaches.Tag.
 
Thanks for responding, I was starting to lose hope.
I found what I was looking for; it is the word "Controls"
Here was the situation:
I have several command buttons on a form (a way for end users to use the form without screwing up)
Pressing a button (let's call it "Peaches") starts other actions and allows for other interactions with the end user, but also passes its name to the tag value of a label (let's call it Bushels).
After a while, a value (e.g. 42) is derived and needs to go back to the Command Button, known only because its name is at Bushels.Tag
Bushels.Tag = 42 only puts the string 42 into the Bushels.Tag
Controls(Bushels.Tag).Tag gets the string 42 into the Peaches.Tag.
 
Back
Top