View Single Post
 
Old 07-27-2024, 08:39 PM
Marcia's Avatar
Marcia Marcia is offline Windows 11 Office 2021
Expert
 
Join Date: May 2018
Location: Philippines
Posts: 553
Marcia has a spectacular aura aboutMarcia has a spectacular aura aboutMarcia has a spectacular aura about
Default Vba to lock cells with formula in a table

Hi all.
I have copied a code that lock cells with formula in a workbook. I would like the code to lock the cells with formula in table "tAbstract" only, not the whole workbook. Would someone please edit the code?
Also, I would like the message "Ooooops formula na" pops up when/if the user accidentally goes to a protected cell.
Thank you for the usual help.

Code:
Sub ProtectFormulaCells()
Dim sh As Worksheet
On Error Resume Next
For Each sh In ActiveWorkbook.Sheets
    With sh
        .Unprotect
        .Cells.Locked = False
        .Cells.SpecialCells(xlCellTypeFormulas).Locked = True
        .Protect
    End With
Next sh
End Sub
Reply With Quote