joelmathew01
New Member
Hello thanks for reading query.
I work in Insurance and spend some time designing spreadsheet for others to use.
query i have - if Cell O2 = " Local" - i want v2, w2, y2, etc to be "white" coloured and locked . so ppl cant use.
if it says " International" - then i want the above mentioned cells to be "yellow" but no locked.
This should run down each rows of the spreadsheet. I can get the highlighting to work but the cell locking is throwing errors.
The below macro works in terms of highlighting the the rows but i cant lock or unlock the cells .
if " Local" is selected - then i want
I work in Insurance and spend some time designing spreadsheet for others to use.
query i have - if Cell O2 = " Local" - i want v2, w2, y2, etc to be "white" coloured and locked . so ppl cant use.
if it says " International" - then i want the above mentioned cells to be "yellow" but no locked.
This should run down each rows of the spreadsheet. I can get the highlighting to work but the cell locking is throwing errors.
The below macro works in terms of highlighting the the rows but i cant lock or unlock the cells .
if " Local" is selected - then i want
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long, r1 As Range, r2 As Range
For i = 9 To 32
Set r1 = Range("o" & i)
Set r10 = Range("AG" & 1)
Set r2 = Range("V" & i, "aa" & i)
Set r3 = Range("AE" & i, "ag" & i)
Set r4 = Range("ai" & i)
If r1.Value = "Local" Then r2.Interior.ColorIndex = 2
If r1.Value = "Local" Then r3.Interior.ColorIndex = 2
If r1.Value = "Local" Then r4.Interior.ColorIndex = 2
If r1.Value = "International" Then r2.Interior.ColorIndex = 19
If r1.Value = "International" Then r3.Interior.ColorIndex = 19
If r1.Value = "International" Then r4.Interior.ColorIndex = 19
If r1.Value = "" Then r2.Interior.ColorIndex = 19
If r1.Value = "" Then r3.Interior.ColorIndex = 19
If r1.Value = "" Then r4.Interior.ColorIndex = 19
Next i
End Sub
Attachments
Last edited by a moderator: