ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Lock condition based on a background fill (https://www.excelbanter.com/excel-programming/356214-lock-condition-based-background-fill.html)

jobeer

Lock condition based on a background fill
 

Obviously an IF condition, but my knowledge ends here...

All I need is a condition that lock all cells in a worksheet, that ha
a background fill. That condition should be activate when openin
workbook

Seems easy, no?

Thanks, ppl! :

--
jobee
-----------------------------------------------------------------------
jobeer's Profile: http://www.excelforum.com/member.php...fo&userid=3244
View this thread: http://www.excelforum.com/showthread.php?threadid=52314


Tom Ogilvy

Lock condition based on a background fill
 
in the Thisworkbook module, use the workbook_open event
http://www.cpearson.com/excel/events.htm

Private Sub Workbook_Open
with worksheets("sheet1")
set rng = .UsedRange
.Unprotect Password:="ABCD"
for each cell in rng
if cell.Interior.ColorIndex < xlNone then
cell.locked = True
end if
Next
.Protect Password:="ABCD"
End with
End Sub

--
Regards,
Tom Ogilvy


"jobeer" wrote:


Obviously an IF condition, but my knowledge ends here...

All I need is a condition that lock all cells in a worksheet, that has
a background fill. That condition should be activate when opening
workbook

Seems easy, no?

Thanks, ppl! :)


--
jobeer
------------------------------------------------------------------------
jobeer's Profile: http://www.excelforum.com/member.php...o&userid=32447
View this thread: http://www.excelforum.com/showthread...hreadid=523145



jobeer[_3_]

Lock condition based on a background fill
 

These cell have values... is there a way to protect them too? :confused


ok, lets say: I have a table with the days of a month (obtained b
formula).
Some days are weekend or hollidays. These particular cells have
background fill.
This worksheet is to set holliday periods for employees. So I don'
want to select Christmas or other hollidays, got it?

So these cells with numbers should be protected, but not for edition
because of the background fill change!

Is this possible

--
jobee
-----------------------------------------------------------------------
jobeer's Profile: http://www.excelforum.com/member.php...fo&userid=3244
View this thread: http://www.excelforum.com/showthread.php?threadid=52314


Tom Ogilvy

Lock condition based on a background fill
 
No I don't got it. I gave you what you asked for. It is unclear how your
additional information has changed that. The only addendum I would add, is
if the sheet is static, you certainly don't need a macro to do this. Set it
up manually and be done with it.

--
Regards,
Tom Ogilvy

"jobeer" wrote:


These cell have values... is there a way to protect them too? :confused:


ok, lets say: I have a table with the days of a month (obtained by
formula).
Some days are weekend or hollidays. These particular cells have a
background fill.
This worksheet is to set holliday periods for employees. So I don't
want to select Christmas or other hollidays, got it?

So these cells with numbers should be protected, but not for edition,
because of the background fill change!

Is this possible?


--
jobeer
------------------------------------------------------------------------
jobeer's Profile: http://www.excelforum.com/member.php...o&userid=32447
View this thread: http://www.excelforum.com/showthread...hreadid=523145




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

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