Conditional Format User Defined Function > 3

fb250r

Board Regular
Joined
Apr 25, 2002
Messages
104
Does anyone have User defined function that allows more than 3 conditions?
 
HELLO FRANK

YOU HAVE TO DEFINE THE RANGE YOU WISH TO CHECK WITH THE NAME
CellsToCheck

this is a macro that you can adapt yo your
needs

Andreas
 
Upvote 0

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hello Frank


You can alter my code like this

Sub CheckCells()
Set RangeToFormat = Sheets("Sheet1").Range("CellsToCheck")
For Each cell In RangeToFormat
With cell
' Empty cells
If IsEmpty(cell) Then
.Interior.ColorIndex = xlNone
' Numeric cells
ElseIf IsNumeric(cell.Value) Then
Select Case cell.Value
Case Is < 0
.Interior.ColorIndex = 7
Case Is < 10
.Interior.ColorIndex = 4
Case Is < 15
.Interior.ColorIndex = 9
Case Is < 20
.Interior.ColorIndex = 10
Case Is < 25
.Interior.ColorIndex = 11
Case Is < 35
.Interior.ColorIndex = 12
End Select
'Error cells
ElseIf IsError(cell.Value) Then 'Error cells
.Interior.Color = 3
' Other cells (text)
Else
.Interior.ColorIndex = xlNone
End If
End With
Next cell
End Sub


Just play with the color index to find what you need

Regards

Andreas
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,849
Members
449,051
Latest member
excelquestion515

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