Conditional Formatting

Matt

Board Regular
Joined
Feb 16, 2002
Messages
212
I'm trying to format a row depending on the value of a single cell within that row. Is it possible to put VB code behind the sheet to set this up. If so, can someone help me with the code. I'm trying to change the colour of the row to red when B2 = Y.

This is the code I get when selecting formatting a single cell but when I place the code behind a sheet, it locks the cell location at B2

Range("B2").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""Y"""
Selection.FormatConditions(1).Interior.ColorIndex = 4

Hope someone can help!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
You don't actually need VBA for this-

Select the entire row that you want to turn red. Click on Format-Conditional Formatting and change 'cell is' to 'formula is' and enter the following: -

=$B$2="Y"

Select your formats and that's it. HTH.
 
Upvote 0
Cheers Mudface

Is there any easy way of copying the formula throughout column B so when a Y appears in a cell in column B, the whole row has a red fill?
 
Upvote 0
There might be a better way of doing this, but this seems to work: -

Select your entire sheet (click on the little grey square between the 'A' and '1' column and row nos). Click on Format- Conditional Formatting and enter: -

=$B1="Y"

as a formula. HTH.
 
Upvote 0

Forum statistics

Threads
1,213,504
Messages
6,114,020
Members
448,543
Latest member
MartinLarkin

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