Rick Rothstein wrote on 2/25/2011 :
You need to change your With statement from this...
With MyRowRange.Interior
to this...
With Intersect(MyRowRange, Target.EntireRow).Interior
because the OP, in his original message, said "I would like it to color
the
background of MyRowRange to the applicable color for that specific row
that
is being intersected with/by the column "M"
Yes, thanks for pointing that out. I did miss this important detail.
Here 's the revised proc...
Private Sub Worksheet_Change(ByVal Target As Range)
Dim MyRowRange As Range
Set MyRowRange = ActiveSheet.Range("A:N")
If Not Intersect(Target, Range("M6:M3000")) Is Nothing Then
With Intersect(MyRowRange, Target.EntireRow).Interior
Select Case Target.Value
Case "RESTRICTED": .ColorIndex = 3 '//red
Case "FULL ACCESS": .ColorIndex = 35 '//light green
Case "LIMITED": .ColorIndex = 6 '//yellow
Case Else: .ColorIndex = 0 '//no fill
End Select '//Case Target.Value
End With '//MyRowRange.Interior
End If '//Not Intersect
End Sub
@Garry,
Would you like to see the functionality of your code reduced to a one-liner
(albeit, a long one)?
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("M6:M3000")) Is Nothing Then Range("A" & _
Target.Row).Resize(1, 14).Interior.ColorIndex = CLng(Split("3 35 6") _
(InStr(1, "RESTRICTED ,FULL ACCESS,LIMITED ", Target.Value, 1) \ 11))
End Sub
@Mick,
Do not even consider for a minute using this code in your actual program... I
just developed it for fun, not for actual use... it would be a nightmare to
maintain.
Rick Rothstein (MVP - Excel)
Awesome, awesome, and awesome! It doesn't handle if the value is
cleared, though. (Range turns red)
--
Garry
Free usenet access at
http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc