Highlight cells based on text

ai1094

Board Regular
Joined
Aug 23, 2018
Messages
92
I have the following table in excel:

V W X Y Z
Project DateModeled Line ItemIncluded in Line ItemBothConfirm Both
Project DateBothConfirm Both
Project DateModeled Line ItemIncluded in Line ItemBothConfirm Both
Project DateModeled Line ItemExcluded Line ItemBothConfirm Both
Project DateModeled Line ItemExcluded Line ItemBothConfirm Both
Project DateBothConfirm Both
Project DateBothConfirm Both

<tbody>
</tbody>


I need help creating a VBA code that will highlight the rows (V:Z) a light red if Column X has Excluded Line Item.
One thing to keep in mind is that Columns V:Z all have formulas in the cells that auto fills to the end of the row so I'm not sure if that will affect the code.

Any help would be great. Thanks!
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Is there any particular reason for needing VBA? This can easily be done with conditional formatting
 
Upvote 0
I have a VBA code that creates this table and a whole bunch of other stuff. I figured I could just include it in the code so I don't have to keep manually putting a conditional format

Is there any particular reason for needing VBA? This can easily be done with conditional formatting
 
Upvote 0
You can add setting up the Conditional Formatting in your VBA code.
Just turn on the Macro Recorder and record yourself performing the Conditional Formatting manually, and you will have recorded most of the VBA code you need to do that.
 
Upvote 0
The problem I am having with that is that only the cell is highlighted. I need the whole row (V:Z) to be highlighted as well.

You can add setting up the Conditional Formatting in your VBA code.
Just turn on the Macro Recorder and record yourself performing the Conditional Formatting manually, and you will have recorded most of the VBA code you need to do that.
 
Upvote 0
Another option would be something like
Code:
Sub ai1094()
   With ActiveSheet
      .Range("V1:Z1").AutoFilter 3, "Exluded line item"
      .AutoFilter.Range.Interior.Color = vbRed
      .Range("V1:Z1").Interior.ColorIndex = xlNone
      .AutoFilterMode = False
   End With
End Sub
 
Upvote 0
This didn't work. My guess is that it's looking for a specific text, but all the cells contain formulas. Could that be an issue?

Another option would be something like
Code:
Sub ai1094()
   With ActiveSheet
      .Range("V1:Z1").AutoFilter 3, "Exluded line item"
      .AutoFilter.Range.Interior.Color = vbRed
      .Range("V1:Z1").Interior.ColorIndex = xlNone
      .AutoFilterMode = False
   End With
End Sub
 
Upvote 0
The problem I am having with that is that only the cell is highlighted. I need the whole row (V:Z) to be highlighted as well.

Press Record

Select V2:Z2000
Enter the conditional formatting formula =($X2="Excluded Line Item") (note only one $)

Press Done
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,729
Members
449,049
Latest member
MiguekHeka

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