![]() |
|
#1
|
||||
|
||||
|
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
|
|
#2
|
||||
|
||||
|
Could you just confirm, tAbstract is (the name of) a proper Excel table (listObject) on a worksheet, and not a worksheet name?
|
|
#3
|
||||
|
||||
|
Quote:
Thank you. |
|
#4
|
||||
|
||||
|
This will work regardless of which sheet you're on as long as the workbook you want it to work in is the active workbook:
Code:
Sub ProtectFormulaCellsInTable_tAbstract()
With Range("tAbstract")
.Parent.Unprotect
.SpecialCells(xlCellTypeFormulas).Locked = True
.Parent.Protect
End With
End Sub
custom error message in popup window for protected cell? | MrExcel Message Board …but is it worth it? |
|
#5
|
||||
|
||||
|
Thank you for the usual quick help and the link. I am using the code that you wrote as is.
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Table Help: lock table structure and collapse/expand parts of table | bsafra1 | Word | 0 | 11-06-2018 03:01 AM |
| Lock items in a table | village | Word | 2 | 06-22-2017 07:33 AM |
| Lock Linked Cells And Unlinked Cells In A Row | paulkaye | Excel | 5 | 07-14-2014 10:20 PM |
How to lock only some cells in 2010 ?
|
spookiepower | Word | 4 | 11-26-2013 02:40 PM |
| Protect / Lock Cells / Print Set-up? | meggenm | Excel | 3 | 01-26-2012 09:57 PM |