Additional requirement to VBA for Coloring in row cell.

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Greetings,

The following VBA works perfecting proving there are no addition text the cell. I can I tweak it just a little to it will highlight anytime the word Local is in the cell no matter if there is data in front or back? Thank you,


VBA Code:
Sub Local_BACKGROUND()
    Sheets("72 Hr").Select
    endrow = Range("E" & Rows.Count).End(xlUp).Row

For Each cell In Range("E3:E" & endrow)
  If cell.Value = "LOCAL" Then
     Range(Cells(cell.Row, "A"), Cells(cell.Row, "E")).Interior.ColorIndex = 6
  End If
Next

End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try this:
VBA Code:
Sub Local_BACKGROUND()
    Sheets("72 Hr").Select
    endrow = Range("E" & Rows.Count).End(xlUp).Row

For Each cell In Range("E3:E" & endrow)
  If InStr(UCase(cell.Value), "LOCAL") > 0 Then
     Range(Cells(cell.Row, "A"), Cells(cell.Row, "E")).Interior.ColorIndex = 6
  End If
Next

End Sub
 
Upvote 0
Solution
Try this:
VBA Code:
Sub Local_BACKGROUND()
    Sheets("72 Hr").Select
    endrow = Range("E" & Rows.Count).End(xlUp).Row

For Each cell In Range("E3:E" & endrow)
  If InStr(UCase(cell.Value), "LOCAL") > 0 Then
     Range(Cells(cell.Row, "A"), Cells(cell.Row, "E")).Interior.ColorIndex = 6
  End If
Next

End Sub
Perfect thank you.
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,576
Members
448,972
Latest member
Shantanu2024

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