Coloring a range depending on a cell value

  • Thread starter Thread starter Jim333
  • Start date Start date
J

Jim333

Hi everybody.

I have created the follwoing code to color a specific range when th
value of cell A1 =1 and uncolor it when it is more than 1.

The problem I faced is that when the code is applied >> the whole shee
becomes un-editable except cell A1, which contains the value.
what I want is to make the whole sheet active and editable afte
applying the follwoing code.


Code
-------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A1").Value = 1 And Target.Address <> "$A$1" Then
Range("B2:F2").Select
With Selection.Interior
.ColorIndex = 6
End With
ElseIf Range("A1").Value > 1 And Target.Address <> "$A$1" Then
Range("B2:F2").Select
With Selection.Interior
.ColorIndex = 0
End With
End If
End Su
 
Thank you for your help .. but this not what I am looking for >>

I want to edit my code if you can do it for me.

Thank you so much
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A1").Value = 1 And Target.Address <> "$A$1" Then
Range("B2:F2").Interior.ColorIndex = 6
ElseIf Range("A1").Value > 1 And Target.Address <> "$A$1" Then
Range("B2:F2").Interior.ColorIndex = xlNone
End If
End Sub
 
Thank you sooooooooo much Tom

That is exactly what I want ..

Thanks alot.

Bye,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top