add colour to row(s)

Trevor3007

Well-known Member
Joined
Jan 26, 2017
Messages
675
Office Version
  1. 365
Platform
  1. Windows
hi


have this code :-
Code:
  Dim Changed As Range, Cell As Range  
  Set Changed = Intersect(Target, Range("m2:k300"))
  If Not Changed Is Nothing Then
    For Each Cell In Changed
      If UCase(Cell.Value) = "YES" Then
        Rows(Cell.Row).Resize(, Cell.Column).Interior.ColorIndex = 35
      Else
        Rows(Cell.Row).Resize(, Cell.Column).Interior.ColorIndex = xlNone
      End If
    Next Cell
    
       
  End If
  end sub


which works ok...but I need to include the following:-

If UCase(Cell.Value) = "EU" Then
Rows(Cell.Row).Resize(, Cell.Column).Interior.ColorIndex = 40

If UCase(Cell.Value) = "issue" Then
Rows(Cell.Row).Resize(, Cell.Column).Interior.ColorIndex = 39

If UCase(Cell.Value) = "BIP" Then
Rows(Cell.Row).Resize(, Cell.Column).Interior.ColorIndex = 4

If UCase(Cell.Value) = "LM" Then
Rows(Cell.Row).Resize(, Cell.Column).Interior.ColorIndex = 15


I have tried to sort but cannot :{

Thank you for your help.
KR
Trevor 3007
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
How about
Code:
 Dim Changed As Range, Cell As Range
 Dim Clr As Long
  Set Changed = Intersect(Target, Range("m2:k300"))
  If Not Changed Is Nothing Then
    For Each Cell In Changed
       Select Case LCase(Cell.Value)
         Case "yes":       Clr = 35
         Case "no":        Clr = 40
         Case "issue":     Clr = 39
         Case "bip":       Clr = 4
         Case "lm":        Clr = 4
         Case Else:        Clr = xlNone
      End Select
      Rows(Cell.Row).Resize(, Cell.Column).Interior.ColorIndex = Clr
    Next Cell
  End If
 
Upvote 0
How about
Code:
 Dim Changed As Range, Cell As Range
 Dim Clr As Long
  Set Changed = Intersect(Target, Range("m2:k300"))
  If Not Changed Is Nothing Then
    For Each Cell In Changed
       Select Case LCase(Cell.Value)
         Case "yes":       Clr = 35
         Case "no":        Clr = 40
         Case "issue":     Clr = 39
         Case "bip":       Clr = 4
         Case "lm":        Clr = 4
         Case Else:        Clr = xlNone
      End Select
      Rows(Cell.Row).Resize(, Cell.Column).Interior.ColorIndex = Clr
    Next Cell
  End If


FANTASTIC...

thank you ...
:beerchug::beerchug::beerchug:
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,880
Messages
6,175,154
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top