Save Macro - Locking & Unlocking Protected Cells

blandreth

Board Regular
Joined
Jan 18, 2018
Messages
56
Office Version
  1. 365
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

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
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,223,954
Messages
6,175,603
Members
452,660
Latest member
Zatman

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