mrMadCat
New Member
- Joined
- Jun 8, 2016
- Messages
- 39
- Office Version
-
- 365
- Platform
-
- Windows
- Mobile
- Web
Hello, I'm trying to run quite a simple macro but it doesn't work and says "object not defined".
The macro is run when the ToggleButton is pressed. So:
Sheet1:
Module1
What I do wrong?
I also have a problem with "ActiveWorkbook.Unprotect" not asking for the password the way wsSh.Unprotect does. The only way is to manually create input box and all the error checks?
The macro is run when the ToggleButton is pressed. So:
Sheet1:
Code:
Private Sub ToggleButton1_Click() Protect_and_Structure
End Sub
Module1
Code:
Sub Protect_and_Structure(wsSh As Worksheet) Dim wsSh As Object
For Each wsSh In Me.Worksheets
If Me.ToggleButton1.Value = True Then
wsSh.Unprotect "PASS"
wsSh.EnableOutlining = True
wsSh.Protect Password:="PASS", Contents:=True, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True, UserinterfaceOnly:=True
Else
wsSh.Unprotect
Next wsSh
' ActiveWorkbook.Unprotect
End If
End Sub
What I do wrong?
I also have a problem with "ActiveWorkbook.Unprotect" not asking for the password the way wsSh.Unprotect does. The only way is to manually create input box and all the error checks?