Highlight a cell through macro

macro_user

Board Regular
Joined
Mar 9, 2009
Messages
101
hi...
i have a loop which runs through column A and column B and if the value of column A is less than the corresponding value(same row index) of column B, then i need to highlight both the cells...
Appreciate the help...
 
i just did trial and error with wat was here and i figured it out :)
Code:
Cells(11, "I").Interior.ColorIndex = 3        'red
Cells(11, "G").Interior.ColorIndex = 6        'yellow

Thanks guys...
 
Upvote 0

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Thanks Schielrn but my requirement was just to highlight it in red... but anyway, would have a look at it after i complete my project :)

Thanks anyways :)
 
Upvote 0
hi... how would i revert all the interior colors to the default one? is the default one is white, how do i do tat? this is because, i highlight few cells in a report... when i re-generate the report, i clear all the cells in the report and then beginning processing...
so when i clear the cells, only the cell contents would be cleared right? i need to revert all the previous highlighted cells to the default color when im trying to regenerate the new report in the same worksheet...
Thanks for ur help...
 
Upvote 0
You could use the clearformatting method.

Rnage("XYZ").clearformats

or set the colorindex to -4142 or I believe you can also use xlcolorindexnone.

Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,215,669
Messages
6,126,117
Members
449,292
Latest member
Mario BR

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