Unlock Sheets via VBA

0

1

I have an excel with a lot of formulas running and it goes to an executive team. Naturally I have locked the two summary pages to prevent formulas from being deleted accidentally but on some systems the file is just slow. I have added a VBA to convert all formulas into values (Pasted below) however it hits a wall on the locked sheets.

How can I have a single Macro that would unlock both Sheets 1 and 2 and convert all into values? (Sheet1 is named "Summary", Sheet2 is named "Details")

Sub AllValues()
Dim wSh As Worksheet
    For Each wSh In ActiveWorkbook.Worksheets
         With wSh.UsedRange
             .Copy
             .PasteSpecial xlPasteValues
          End With
    Next wSh
    Application.CutCopyMode = False
End Sub

Thank you!

ndocds

Posted 2019-02-21T19:02:05.977

Reputation: 47

Are they locked via Password protection? If not, just try wsh.Unprotect. Also, it may be quicker instead of copy/pasting, to just do wsh.UsedRange.Value = wsh.UsedRange.Value (essentially, just set the values equal to eachother). – BruceWayne – 2019-02-21T20:04:04.713

It's not locked via a passcode just locked to preview accidental deletion because I already got the "Why is there just a + there did you screw something up" comment. – ndocds – 2019-02-21T20:16:34.057

No answers