I am trying to lock and grey out "A3" and "A4" depending on "A1"
I imagine it's something like this.
Sub workscopecell() If Target.Address = "A1" Then If Target.Value = "Activate" Then Range("A3") And Range("A4").Interior.Color = RGB(192, 192, 192) ActiveSheet.Cells.Locked = False Range("A3") And Range("A4").Locked = True ActiveSheet.Protect Else ActiveSheet.Unprotect Range("J13").Interior.ColorIndex = xlNone End If End If End Sub
...etc.Range("A3:A4").Interior.Color = RGB(192, 192, 192)
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Hi,
What's the trigger for this? It seems that it should probably be a Worksheet Change event, but your procedure seems to be a normal sheet/module level procedure.
If so try
Private Sub Worksheet_Change(ByVal Target As Range) If Target = Range("A1") And Target.Value = "Activate" Then Range("A3:A4").Interior.Color = RGB(192, 192, 192) ActiveSheet.Cells.Locked = False Range("A3:A4").Locked = True ActiveSheet.Protect Else ActiveSheet.Unprotect Range("J13").Interior.ColorIndex = xlNone End If End Sub
Richard Buttrey
If this was useful then please rate it appropriately.
Click the small star iconat the bottom left of my post.
Woohoo! It works, but it's displaying a error message- "Range("A3:A4").Interior.Color = RGB(192, 192, 192)" Is there anyway to disable to error msg?
No, don't suppress errors, fix the code. What color did you want the interior? Grey?
Range("A3:A4").Interior.ColorIndex = 15
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks