Macro "on off" switch

L

Larry Fitch

I have a very simple macro assigned to a button that unhides a sheet

Sub HR_Training()
'
' HR_Training Macro
' Unhide only the HR Training Hard Dollar Cost Savings Sheet
'

'
Application.ScreenUpdating = False
Sheets("HR - Training").Visible = True
Sheets("Selection Sheet").Select
End Sub
--

What I would like to do is add a "toggle" type of functionality so that the
first press of the button will unhide the sheet, and the next time it will
hide it..

any help would be most appreciated..
Thanks

Larry
 
J

Jim Thomlinson

Try this...

Sub HR_Training()
'
' HR_Training Macro
' Unhide only the HR Training Hard Dollar Cost Savings Sheet
'

Sheets("HR - Training").Visible = not Sheets("HR - Training").Visible
End Sub
 
S

Sheeloo

Use
Sheets("HR - Training").Visible = Not Sheets("HR - Training").Visible

in place of
Sheets("HR - Training").Visible = True
 

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

Similar Threads


Top