combining two short VBA scripts from two buttons
Sub Button8_Click()
With Range("J2:Q2")
.EntireColumn.Hidden = not .EntireColumn.Hidden =
End With
End Sub
--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
wrote in message
oups.com...
learning VBA and Macros in Excel, so forgive my newbie-ness.
I have two button forms, each with it's own macro.
Sub Button8_Click()
Range("J2:Q2").Select
Selection.EntireColumn.Hidden = True
End Sub
Sub Button9_Click()
Range("I2:R2").Select
Selection.EntireColumn.Hidden = False
Range("G2").Select
End Sub
One button(8) hides columns, the other button(9) reveals them. Is
there a simple bit of code that will allow me to combine these
functions onto one button? The macro that runs on click would depend on
the state of the sheet. If columns are hidden, the button would run
the "unhide" macro; if columns are unhidden, the button would run the
"hide" macro.
Also, as a nice touch, the button text would change to reflect
appropriate pending action.
This is, I guess, a basic on/off situation, but I can't figure it out.
:(
|