Shape as a Macro Button - How to Toggle Text in Button

lac0403

Board Regular
Joined
Apr 25, 2008
Messages
50
I have a workbook with a lot of sheets, so we hide/unhide some as needed. I am trying to setup a toggle "button" that has been created with a shape & text. In the macro I would like the shape text to change between hide and show. I have tried several ways, but none seem to work. I drop the buttons on the sheets directly, they are not in user forms. Command buttons have not been used, because of limitations in formatting. (But I can change if this is the only way)

Code:
[FONT=Calibri]Sub MacroVisible2()[/FONT]
[FONT=Calibri]
With Worksheets("Macros")[/FONT]
[FONT=Calibri].Visible = Not.Visible[/FONT]
[FONT=Calibri].Shapes("btnHS_Macro").TextFrame.Characters.Text= IIf(.Visible, "Hide Macro Sheet", "Show Macro Sheet")[/FONT]
[FONT=Calibri]End With[/FONT]

[FONT=Calibri]If Sheets("Macros").Visible = True ThenSheets("Macros").Activate[/FONT]

[FONT=Calibri]End Sub[/FONT]

As always, the great help here is appreciate.

P.S. As a bonus, if there is a better way to activate the sheet if it is made visible, I am open to learning.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
That code works for me though it does hide the sheet the button is on.
 
Upvote 0
And yet your feedback clears it up for me.....the button is on a different sheet. Sometimes you just need fresh eyes! I feel foolish....and yet grateful! Thanks!
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,175
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top