Macros and buttons

S

Sandy

Hi

I have 2 macros A and B say and two buttons Cand D on a worksheet. Can I
have button C run Macro A and then at the end of the code make C invisisble
and D visible. Then have button D run Macro B and at the end of the code
make C visible and D invisible - am I making myself clear?
The buttons were placed on the sheet from the form toolbar.

Sandy
 
J

JE McGimpsey

One way:

Attach macro A to button C. In Macro A, include the lines:

Worksheets("Sheet1").Buttons("Button C").Visible = False
Worksheets("Sheet1").Buttons("Button D").Visible = True

(adjust the names to suit). Put the opposite configuration in Macro B.
 
G

Guest

Sandy,

Here's an example with 2 buttons (Button 1 and Button 2). Clicking one
button hides itself and shows the other.


Sub Button1_Click()
ActiveSheet.Shapes("Button 1").Visible = False
ActiveSheet.Shapes("Button 2").Visible = True
End Sub

Sub Button2_Click()
ActiveSheet.Shapes("Button 1").Visible = True
ActiveSheet.Shapes("Button 2").Visible = False
End Sub
 
S

Sandy

Hi

I get the gist of it but how do I find the "name" of the buttons, - stupid
question but I am dumb at controls etc

Sandy
 
S

Sandy

Hi

I get the gist of it but how do I find the "name" of the buttons, - stupid
question but I am dumb at controls etc

Sandy
 
J

JE McGimpsey

Select the button (right-click it), and look in the Name box on the left
side of the formula toolbar.
 
S

Sandy

Thank you - working perfectly now
Sandy

JE McGimpsey said:
Select the button (right-click it), and look in the Name box on the left
side of the formula toolbar.
 

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

Similar Threads


Top