need help with conditional formatting cells

tonyjyoo

Board Regular
Joined
Aug 5, 2016
Messages
167
Hello,

I have a cell that reads a percent (e.g. A1 = 5%).

How can I conditional format the rest of the cells in the column (e.g. A2:A20) to highlight red text if their absolute value is less than A1? Examples of highlighted cells would be 4%, -2%... but not -10%).


 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Select cells A2:A20.
Go to Conditional Formatting.
Enter this formula in the Conditional Formatting formula option:
Code:
=ABS(A2)<$A$1
Choose your red text formatting condition.
Click OK.

That should do it.
 
Upvote 0
Select cells A2:A20.
Go to Conditional Formatting.
Enter this formula in the Conditional Formatting formula option:
Code:
=ABS(A2)<$A$1
Choose your red text formatting condition.
Click OK.

That should do it.

Didn't work.

Also, shouldn't the formula be cells A2:A20?
 
Upvote 0
Didn't work.

Also, shouldn't the formula be cells A2:A20?
I am guessing that maybe you didn't follow my instructions exactly as I described them.
I set up your example, and it highlighted the exact values you wanted.
Please go back, read it very carefully, and do exactly what it says. It should work, as long as your entries really are numerical percentages and not text.

The key here is to first select the ENTIRE range that you want to apply it to (hence, the select A2:A20) step.
Then, write the Conditional Formatting formula as it applies to the very first cell in your selection (A2).
If you use Absolute and Relative range referencing properly (which I did), Excel will automatically adjust for the rest of the cells. We want to lock down A1, hence $A$1. But we do not want to lock down A2.
See here for an explanation on Range Referencing: http://www.cpearson.com/excel/relative.aspx
 
Last edited:
Upvote 0
I am guessing that maybe you didn't follow my instructions exactly as I described them.
I set up your example, and it highlighted the exact values you wanted.
Please go back, read it very carefully, and do exactly what it says. It should work, as long as your entries really are numerical percentages and not text.

The key here is to first select the ENTIRE range that you want to apply it to (hence, the select A2:A20) step.
Then, write the Conditional Formatting formula as it applies to the very first cell in your selection (A2).
If you use Absolute and Relative range referencing properly (which I did), Excel will automatically adjust for the rest of the cells. We want to lock down A1, hence $A$1. But we do not want to lock down A2.
See here for an explanation on Range Referencing: http://www.cpearson.com/excel/relative.aspx

I followed your EXACT steps, but nothing is being highlighted even after I changed it to be red text...
 
Upvote 0
What does this formula return?
=ISNUMBER(A2)
 
Upvote 0
returns false because that cell happens to be blank (I have an iferror set up for any cells to be blank in the column if it's not divisible by 0)
 
Upvote 0
Can you try it on a cell that has an entry in it?
What exactly is the formula you have in these cells?
Can you post it here?

In order for me to determine why it isn't working for you, I need to try to set up a sheet on my side that is set up the same way yours is. So I need those details.
 
Last edited:
Upvote 0
Here is VBA code that will set-up and sample data and the Conditional Formatting.

Run this on any blank sheet, and you will see how it works.
Then compare it to what you have to see what the difference is.
Code:
Sub Test()

'   Enter sample data
    Range("A1").FormulaR1C1 = "5%"
    Range("A2").FormulaR1C1 = "4%"
    Range("A3").FormulaR1C1 = "-2%"
    Range("A4").FormulaR1C1 = "-10%"
    Range("A5").FormulaR1C1 = "7%"
    
'   Apply Conditional Formatting
    With Range("A2:A20")
        .FormatConditions.Add Type:=xlExpression, Formula1:= _
            "=ABS(A2)<$A$1"
        .FormatConditions(.FormatConditions.Count).SetFirstPriority
        With .FormatConditions(1).Font
            .Color = -16776961
            .TintAndShade = 0
        End With
        .FormatConditions(1).StopIfTrue = False
    End With
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,429
Messages
6,124,840
Members
449,193
Latest member
MikeVol

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