Save Macro - Locking & Unlocking Protected Cells

blandreth

Board Regular
Joined
Jan 18, 2018
Messages
52
I have the following save macro that unlocks a cell, saves the file with a new name and then locks the cell again to protect a formula. The issue I'm having is when it locks the sheet again, it does not allow my pictures in the report to be modified. Is there something I can add to the code, that will check the "edit object" & "edit scenarios" during the cell lock function?

Sub SaveFile()
'
' SAVEFILE Macro
'Dim sNameSheet As String

sNameSheet = Range("NAME").Value

ActiveSheet.Unprotect "password"
Sheets("report").Range("Date").Value = Now()
ActiveSheet.Protect "password"

ActiveWorkbook.SaveAs Filename:="C:\documents" & sNameSheet

'
End Sub


I appreciate the help and feedback.

Thanks,
Brian
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Try recording a macro while you manually protect a sheet with the check boxes selected that you want. Copy the parameters of the recorded Activesheet.Protect line to your code.
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,148
Members
448,552
Latest member
WORKINGWITHNOLEADER

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top