Buttons

D

Dave

Hi,
XL2003
I have some buttons on the Worksheet (from the Forms toolbar) which fire
specific macros.
Can VBA return (to a variable) the text of the button that fired it?
Regards - Dave.
 
T

Tim Williams

Application.Caller will give you the name of the button.

You can get the text using the name.

Tim
 
D

Dave

Hi Tim,
Thanks for your help. But still stuck.
I have:

A = Application.Caller
B = ActiveSheet.Shapes(A).Characters.Text

The first line is working.
But the second line gives an error. Can you please point me to the right
syntax?
Regards - Dave.
 
J

john

see if this works for you.

A = Application.Caller
b = ActiveSheet.Buttons(A).Characters.Text
 
D

Dave

Hi John,
Thanks! When I modified the button with the macro recorder turned on, the
syntax used 'Shapes', But 'Buttons' works and Shapes doesn't, so pooh to the
macro recorder, and hats of to you.
Regards - Dave.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top