CONDITIONAL FORMATTING w/if function

SDKBRK

Board Regular
Joined
Feb 1, 2003
Messages
162
I have a spreadsheet and I want a cell to change colors when it does not match my criteria.
If cell C10 = 1, cell V10 should not be over 1.2, if its over turn RED.
If cell C10 = 2, cell V10 should not be over 4.0.

I want this in cell V10 using conditional formatting.

Thanks.
di
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
IT's not pretty but this works. I could clean it up pretty easily.

NOTE: You need to put this in the Folder: MicrosoftExcelObjects And click on the Sheet



Private Sub Worksheet_Change(ByVal Target As Range)


If Target.Address = "$C$10" Then
' First Reset to normal colors
Range("V10").Select
Selection.Font.ColorIndex = 0
Selection.Interior.ColorIndex = xlNone

'Test for conditions
' C10 = 1
If Range("C10") = 1 Then
If Range("V10") > 1.2 Then
Range("V10").Select
Selection.Font.ColorIndex = 3
End If
End If

' And another one for C10 = 2
If Range("C10") = 2 Then
If Range("V10") > 4 Then
Range("V10").Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
End If
End If

End If

If Target.Address = "$V$10" Then
' First Reset to normal colors
Range("V10").Select
Selection.Font.ColorIndex = 0
Selection.Interior.ColorIndex = xlNone

'Test for conditions
' C10 = 1
If Range("C10") = 1 Then
If Range("V10") > 1.2 Then
Range("V10").Select
Selection.Font.ColorIndex = 3
End If
End If

' And another one for C10 = 2
If Range("C10") = 2 Then
If Range("V10") > 4 Then
Range("V10").Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
End If
End If

End If

End Sub
 
Upvote 0
SDKBRK said:
I have a spreadsheet and I want a cell to change colors when it does not match my criteria.
If cell C10 = 1, cell V10 should not be over 1.2, if its over turn RED.
If cell C10 = 2, cell V10 should not be over 4.0.

I want this in cell V10 using conditional formatting.

Thanks.
di
Hi di:

One way to do this is to use the following Conditional Formatting formula in cell V10 ...

=$V$10>CHOOSE($C$10,1.2,4,valFor3,valFor4,"...")
... pattern RED
 
Upvote 0
It works......

Thank you so much the fomula using CHOOSE it works. It took me a few mins to figure out how it works but it works.

Thanks again
di
 
Upvote 0

Forum statistics

Threads
1,222,248
Messages
6,164,813
Members
451,917
Latest member
WEB78

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