Change macro button text when macro is invoked.

  • Thread starter Thread starter Tonso
  • Start date Start date
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
 
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
 
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
 
Back
Top