Change macro button text when macro is invoked.

T

Tonso

In xl2007, I created a simple macro to hide or unhide columns [Columns("H:L").EntireColumn.Hidden = Not Columns("H:L").EntireColumn.Hidden]. I inserted a "Button - Form Control" to invoke it. It works fine. The text on the button is "Show Rate". I was wondering if there was a way to make the text change, depending on the state of the columns, so if they were hidden, the button text would read "Show Rate", and if the were unhidden, the button text would read "Hide Rate. As i said, the macro works fine...I was just wondering if this was possible, and if so, how?

Thanks,

Tonso
 
C

Claus Busch

Hi,

Am Mon, 5 Nov 2012 06:44:35 -0800 (PST) schrieb Tonso:
In xl2007, I created a simple macro to hide or unhide columns [Columns("H:L").EntireColumn.Hidden = Not Columns("H:L").EntireColumn.Hidden]. I inserted a "Button - Form Control" to invoke it. It works fine. The text on the button is "Show Rate". I was wondering if there was a way to make the text change, depending on the state of the columns, so if they were hidden, the button text would read "Show Rate", and if the were unhidden, the button text would read "Hide Rate. As i said, the macro works fine...I was just wondering if this was possible, and if so, how?

do it with an activeX button:

Private Sub CommandButton1_Click()
Columns("H:L").EntireColumn.Hidden = _
Not Columns("H:L").EntireColumn.Hidden
CommandButton1.Caption = IIf(Columns("H:L").EntireColumn.Hidden, _
"Show Rate", "Hide Rate")
End Sub


Regards
Claus Busch
 
T

Tonso

In xl2007, I created a simple macro to hide or unhide columns [Columns("H:L").EntireColumn.Hidden = Not Columns("H:L").EntireColumn.Hidden]. I inserted a "Button - Form Control" to invoke it. It works fine. The text on the button is "Show Rate". I was wondering if there was a way to make the text change, depending on the state of the columns, so if they were hidden, the button text would read "Show Rate", and if the were unhidden, the button text would read "Hide Rate. As i said, the macro works fine...I was just wondering if this was possible, and if so, how? Thanks, Tonso

Claus,

Thank you so much! That works great!

Thanks again...
Tonso
 

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