Change row fill color depending on cell value

Nick70

Active Member
Joined
Aug 20, 2013
Messages
299
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have some data in range (A2:Z100) in Sheet1.

I would like rows to have yellow fill color if cell in column B contains text "pear".
I would like rows to have green fill color if cell in column B contains text "apple".

It is not entire row that must change fill only between column A and Z.

So if cell B5 contains text "pear" then Range(A5:Z5) will change color.

How do I do that?

Thanks,
N. :unsure:
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Use Conditional Formatting formulas.

First, select the range A2:Z100.
Then go to Conditional Formatting and choose the formula option, and enter the formula:
Excel Formula:
=$B2="pear"
and choose yellow fill color formatting option.

Repeat the process, setting up a second rule for the "apple" option.
 
Upvote 0
Solution
You are welcome!
Glad I was able to help.
 
Upvote 0
Hi Joe4,

Quick question.
Because I need to apply this conditional formatting to a new sheet every day is there a way to insert this conditional formatting using a macro?
So can we use a code that inserts conditional formatting =$B2="pear" for a specific range?

Could I for example record a macro as I apply this conditional formatting and then save it?

Thanks,
:unsure:
 
Upvote 0
In fact I recorded conditional formatting and saved as macro and works fine!
 
Upvote 0

Forum statistics

Threads
1,215,248
Messages
6,123,869
Members
449,130
Latest member
lolasmith

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