ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Conditional Formatting a range of cells (https://www.excelbanter.com/excel-programming/297646-re-conditional-formatting-range-cells.html)

Shwaibri

Conditional Formatting a range of cells
 
But here is a really really basic macro that will change it to red i
the active cell's value is greater than 5, change to blue if less tha
5, or change to black (automatic) if it equals 5. I don't know how t
have it work over an entire selection instead of just the active cell
I'm sure someone else can help out with that, but what I do is jus
start recording a macro, assign a shortcut key to it (like "r") an
this macro will automatically drop down to the next cell below th
active one after running the macro (activecell.offset(1,0).

Sub Colorchange()

If ActiveCell 5 Then 'Change the 5 to you
value
ActiveCell.Interior.ColorIndex = 3 'ColorIndex 3 = red
Else
If ActiveCell < 5 Then 'Change the 5 to you
value
ActiveCell.Interior.ColorIndex = 5 'ColorIndex 5 = blue
Else
If ActiveCell = 5 Then 'Change the 5 to you
value
ActiveCell.Interior.ColorIndex = 1 'ColorIndex 1 = black
End If
End If
End If
ActiveCell.Offset(1, 0).Select
End Sub


By setting this macro to a keyboard shortcut you can easily jump dow
the column, if you want to scroll across rows then change th
Offset(1,0) to Offset(0,1).Select

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 11:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com