I am having a problem that I can't seem to figure out. The code below works well when attached to a button on a userform but
I cannot for the life of me make it work with a button inserted into an excel sheet. Depending on what I do, I get Runtime errors that point to an
object error. I am guessing that a button inserted into excel does not have a property option called 'caption' thus causing the problem... but I am
just guessing.
Any guidance would be helpful as I am pretty new to all things vba and am easily stumped.
................................
Private Sub Hidebtn_Click()
'Operates a button that displays the status of rows 10 to 31
'If rows are visible then the button displays a caption of "Hide Register"
'Once pressed rows 10:31 are hidden and the caption changes to "Show Register"
'Pressed again the rows are unhidden and the caption on the button changes back to "Hide Register"
If Hidebtn.Caption = "Hide Register" Then
Range("10:31").EntireRow.Hidden = True
Hidebtn.Caption = "Show Register"
Else
Range("10:31").EntireRow.Hidden = False
Hidebtn.Caption = "Hide Register"
End If
End Sub
...............................................
Thanks In Advance
Scott
Bookmarks