ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Protecting cells by coluor (https://www.excelbanter.com/excel-programming/345353-protecting-cells-coluor.html)

st120869

Protecting cells by coluor
 

I have used 3 colours in my spreadsheet 1 for headings /titles, 1 fo
data entry and 1 for calculated fields. How can I protect all cell
with a specific colour to prevent users from changing contents
formul

--
st12086
-----------------------------------------------------------------------
st120869's Profile: http://www.excelforum.com/member.php...fo&userid=1833
View this thread: http://www.excelforum.com/showthread.php?threadid=48424


Rowan Drummond[_3_]

Protecting cells by coluor
 
Protects all cells which are coloured Light Yellow (colour index 36):

Sub PrtcColor()
Dim cell As Range
With ActiveSheet
.Unprotect
For Each cell In .UsedRange
If cell.Interior.ColorIndex = 36 Then
cell.Locked = True
Else
cell.Locked = False
End If
Next cell
.Protect
End With
End Sub

Hope this helps
Rowan

st120869 wrote:
I have used 3 colours in my spreadsheet 1 for headings /titles, 1 for
data entry and 1 for calculated fields. How can I protect all cells
with a specific colour to prevent users from changing contents /
formula



st120869[_2_]

Protecting cells by coluor
 

Great, thanks this works. As an aside it will not work if any cells are
merged - took a while to work this one out as I kept on getting an
error message.


--
st120869
------------------------------------------------------------------------
st120869's Profile: http://www.excelforum.com/member.php...o&userid=18330
View this thread: http://www.excelforum.com/showthread...hreadid=484245


Rowan Drummond[_3_]

Protecting cells by coluor
 
You're welcome. You will find a lot of things don't work with merged
cells. As a result I never use them.

Regards
Rowan

st120869 wrote:
Great, thanks this works. As an aside it will not work if any cells are
merged - took a while to work this one out as I kept on getting an
error message.




All times are GMT +1. The time now is 02:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com