Livin404
Well-known Member
- Joined
- Jan 7, 2019
- Messages
- 743
- Office Version
- 365
- 2019
- Platform
- Windows
Greetings, I have a fairly complex worksheet that automatically corrects errors with the activation of a button. All seems to be well regarding working the buttons. It is because I have to protect the sheet, it is the AutoFit macro which is causing the problems. Do I need to have "Call Sheet Protection" for every macro? Any help with this would be great for it's driving me mad.
Thank you for much indeed.
VBA Code to protect the worksheet (This has it's own Module:
VBA Code for Auto Fit- (This is not in a module but rather in Sheet1 (Xman):
Thank you for much indeed.
VBA Code to protect the worksheet (This has it's own Module:
VBA Code:
Sub SheetProtection()
If ThisWorkbook.Sheets("Xman").ProtectContents = True Then
ThisWorkbook.Sheets("Xman").Unprotect "mozzer"
Else
ThisWorkbook.Sheets("Xman").Protect "mozzer"
End If
End Sub
VBA Code for Auto Fit- (This is not in a module but rather in Sheet1 (Xman):
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Call SheetProtection
Columns.AutoFit
Call SheetProtection
End Sub