Changing cell color base on condition

rubic

Active Member
Joined
Jul 9, 2008
Messages
251
I have table with data from Column A to Column P. I want to create a sub routine that enables to change the background color to "grey" if the entry in Column O is the word "Closed".
Appreciate your help.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
How about with conditional formatting...

Highlight Column A - P and in format > conditional formatting > formula Is enter =$O1="Closed"
 
Upvote 0
Thanks for the suggestion. As the range of cells are quite large I have already used conditional formatting for other purposes, I think a vba solution would be most fitting.
 
Upvote 0
Who needs VBA?

Excel Workbook
ABCDEFGHIJKLMNOP
1BinaryOctDecHexGlyphBinaryOctDecHexGlyphBinaryOctDecHexStatusGlyph
2010 0000403220?100 00001006440@110 00001409660Open`
3010 0001413321!100 00011016541A110 00011419761Closeda
4010 0010423422"100 00101026642B110 00101429862Openb
5010 0011433523#100 00111036743C110 00111439963Openc
6010 0100443624$100 01001046844D110 010014410064Opend
7010 0101453725%100 01011056945E110 010114510165Opene
8010 0110463826&100 01101067046F110 011014610266Openf
9010 0111473927'100 01111077147G110 011114710367Openg
10010 1000504028(100 10001107248H110 100015010468Openh
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A21. / Formula is =$O2="Closed"Abc
 
Upvote 0
Code:
Sub Colours()
Dim i As Integer
For i = 2 To 100
    Select Case Range("O" & i).Value
    Case "Closed": Range("A" & i & ":P" & i).Interior.ColorIndex = 5
    End Select
Next i
End Sub

Enjoy :biggrin:
 
Upvote 0
Stormseed,

Thanks for your help. In your code
Code:
For i = 2 To 100
is this referring to row 2 to 100?
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,812
Members
449,048
Latest member
greyangel23

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