Toggle Button Text Excel 2007

Reimer
3StarLounger
Posts: 233
Joined: 10 Feb 2010, 19:17

Toggle Button Text Excel 2007

Post by Reimer »

HI,
I did search but did not find what I was looking for, so I figured I would post the question.
I would like a button on an Excel 2007 worksheet that is assigned to a macro (that part is easy).

I would like the macro to be able to change the text of the button so the user knows what will happen when it is pressed.
For example the same button says "Press to Hide the Formulas", when the formulas are showing and "Press to Show the Formulas" when the formulas are hidden.
This is not on a userform -just a button on a worksheet.
Any thoughts?

Thanks for reading.
Chuck Reimer
(I'm from the Government and I'm here to help) ;-)

TCJammer
NewLounger
Posts: 5
Joined: 18 Feb 2010, 14:32

Re: Toggle Button Text Excel 2007

Post by TCJammer »

You need to use the .caption property of the button. Use code simular to below but change the cmdbtnShowFormulas to the name of your button and change the PassedWS to the name of the worksheet.

Such as:

With Worksheets(PassedWS)

if .cmdbtnShowFormulas.Caption = "Press to Hide the Formulas" then
.cmdbtnShowFormulas.Caption = "Press to Show the Formulas"
else
.cmdbtnShowFormulas.Caption = "Press to Hide the Formulas"
end if

End With

Reimer
3StarLounger
Posts: 233
Joined: 10 Feb 2010, 19:17

Re: Toggle Button Text Excel 2007

Post by Reimer »

TCJammer,

Thanks! I will give it a try.
Chuck Reimer
(I'm from the Government and I'm here to help) ;-)

Reimer
3StarLounger
Posts: 233
Joined: 10 Feb 2010, 19:17

Re: Toggle Button Text Excel 2007

Post by Reimer »

Got it working.
Thanks so much for taking the time to help out.
Have a Great Day.
Chuck Reimer
(I'm from the Government and I'm here to help) ;-)

TCJammer
NewLounger
Posts: 5
Joined: 18 Feb 2010, 14:32

Re: Toggle Button Text Excel 2007

Post by TCJammer »

You are most welcome.