Can someone tell me why this will work in the before save module if I use Excel's save button, but not my own save macro?
Here is the code I have in my save macro:
If I take the code out of the before save macro and put it directly in my save macro, it will work, but now not with Excel's save button, obviously.
The error I get is:
Select method of Range Class failed
Thanks
Code:
Dim Revert As String
Dim ws As Worksheet
Revert = ActiveSheet.Name
For Each ws In Sheets
ws.Activate
If ActiveCell.Address <> "D5" Then
ws.Unprotect Password:="17Lj041kM"
ws.Range("A1").Select
ws.Range("D5").Select
ws.Protect AllowFormattingCells:=True, Password:="17Lj041kM"
End If
Next
Sheets(Revert).Activate
Here is the code I have in my save macro:
Code:
ThisWorkbook.Save
If I take the code out of the before save macro and put it directly in my save macro, it will work, but now not with Excel's save button, obviously.
The error I get is:
Select method of Range Class failed
Thanks