VBA To Highlight Row ??

mayoung

Active Member
Joined
Mar 26, 2014
Messages
257
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I am trying to come up with some code that loops through column I and if it Contains ("*NOT*") or Starts with ("*SHOP WAIT") it will highlight the row A:BI.
My one example Highlights the entire row. The second does nothing. Can either one or both be modified to do what I want?

VBA Code:
       Dim Cell As Range, Addr As String
   With Range("I2", Cells(Rows.Count, "I").End(xlUp))
    Set Cell = .Find("*NOT*", , xlValues, , , , False, , False)
    If Not Cell Is Nothing Then
      Addr = Cell.Address
      Do
        Cell.EntireRow.Interior.Color = RGB(255, 167, 155)
 '      Cell.EntireRow.Interior.ColorIndex = 6
        Set Cell = .FindNext(Cell)
      Loop While Not Cell Is Nothing And Cell.Address <> Addr
    End If
  End With

   With Range("I2", Cells(Rows.Count, "I").End(xlUp))
    Set Cell = .Find("*SHOP WAIT", , xlValues, , , , False, , False)
    If Not Cell Is Nothing Then
      Addr = Cell.Address
      Do
'        Cell.EntireRow.Interior.Color = RGB(255, 167, 155)
        Cell.EntireRow.Interior.ColorIndex = 6
        Set Cell = .FindNext(Cell)
      Loop While Not Cell Is Nothing And Cell.Address <> Addr
    End If
  End With

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    Dim myCell As Range

    For Each myCell In Range("I2:I" & Range("I" & Rows.Count).End(xlUp).Row)
        If myCell.Value = "*NOT*" Then Intersect(myCell.EntireRow, Range("A:BI")).Interior.Color = RGB(255, 167, 155)
        If myCell.Value = "*SHOP WAIT" Then Intersect(myCell.EntireRow, Range("A:BI")).Interior.ColorIndex = 6
    Next
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Maybe...
VBA Code:
 Do
   Range("A" & Cell.Row & ":BI" & Cell.Row).Interior.Color = RGB(255, 167, 155)

M.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,036
Messages
6,122,794
Members
449,095
Latest member
m_smith_solihull

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