Change adjacent cell color

trenny

New Member
Joined
Feb 15, 2010
Messages
23
I know this has to be easy, but can't think of or find a solution!<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
I receive 1000 .csv reports every week. My job is to format them so that they look "pretty" when printed. I have been able to write/record a macro to do everything except the following:
In cell h7 on every report, there is either an "x" or no value. Based on this data, I need to change the interior color of cells h7, h6, h5, and h4 to red.
I also need to do this for cell g30 and o30, but should be able to use the same solution.
Any help is appreciated.<o:p></o:p>
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi
It sounds like a job for Conditional Formatting. Select the cells H4 to H7 and G30 and O30 (using CTRL key for multiple selections). Select Format | Conditional Formatting and Formula Is from the drop down. Then enter the following formula and choose the interior colour that you want and click OK.

=$H$7="x"

Cheers

Gordon
 
Upvote 0
I was hopiong to do this using a macro. I have 1000 files to work on. Something like:

if cells(h7).value = "x" then offset(0,-1) color = red
 
Upvote 0
I was doing it right all along, but it wasn't working before, but now it is???

For anyone else, here is a snippet of the code:

Range("H7").Select
If ActiveCell.Value = "x" Then
ActiveCell.Interior.ColorIndex = 3
ActiveCell.Offset(0, -1).Interior.ColorIndex = 3
ActiveCell.Offset(0, -2).Interior.ColorIndex = 3
ActiveCell.Offset(0, -3).Interior.ColorIndex = 3
ActiveCell.Offset(0, -4).Interior.ColorIndex = 3
End If

I just repeat it for each cell I need to evauluate.
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,299
Members
452,904
Latest member
CodeMasterX

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