![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: England
Posts: 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! |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
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. |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: England
Posts: 212
|
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? |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
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. |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Feb 2002
Location: England
Posts: 212
|
Thats worked a treat, thanks mudface
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|