cdharguth
03-06-2020, 09:46 AM
Hi all,
I've assigned two macros to two separate shapes. One macro protects sheets in the workbook:
Sub ProtectSheets()
Dim wsheet As Worksheet
For Each wsheet In ActiveWorkbook.Worksheets
wsheet.Protect Password:="econdev"
Next wsheet
End Sub
The other unprotects:
Sub UnprotectSheets()
Dim wsheet As Worksheet
For Each wsheet In ActiveWorkbook.Worksheets
wsheet.Unprotect Password:="econdev"
Next wsheet
End Sub
Rather than have two separate buttons I would like to merge them into one, toggling between the text "Hide Sheets" and "Unhide Sheets." When the button is first clicked, the UnhideSheets macro will run and the button text will switch to "Hide Sheets" and run the HideSheets macro with the next click.
Please advise!
I've assigned two macros to two separate shapes. One macro protects sheets in the workbook:
Sub ProtectSheets()
Dim wsheet As Worksheet
For Each wsheet In ActiveWorkbook.Worksheets
wsheet.Protect Password:="econdev"
Next wsheet
End Sub
The other unprotects:
Sub UnprotectSheets()
Dim wsheet As Worksheet
For Each wsheet In ActiveWorkbook.Worksheets
wsheet.Unprotect Password:="econdev"
Next wsheet
End Sub
Rather than have two separate buttons I would like to merge them into one, toggling between the text "Hide Sheets" and "Unhide Sheets." When the button is first clicked, the UnhideSheets macro will run and the button text will switch to "Hide Sheets" and run the HideSheets macro with the next click.
Please advise!