How do you conditionally format cell using absolute values and relative cell references?

xcelnovice101

Active Member
Joined
Aug 24, 2012
Messages
368
Below is my code which isn't formatting the cells it's suppossed to. It looks like it isn't doing anything. I think the issue might be with the highlighted section of my code, but when I go to "Manage" my rules for conditional formatting, excel references the appropriate cell under the "Applies to" section. I am using relative cell references for for the majority of the rest of the code and this section follows a section that selects the correct cell for this conditional format.

Code:
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=""ABS[COLOR=#ff0000]()[/COLOR]>.005"""
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 255
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
The formula that works in excel is =ABS($O$101)>0.005 for range O101. The differences between this and my code that isn't working are the "" in front of ABS and the "" in front of the last " behind .005 as well as the explicit reference of the range. Is there a way of referencing the cell using relative cell referencing or is there a way I can create a variable where the code will input the appropriate range? Maybe something like Formula1:="=ABS(" & Rng & ").0.005" I'm just not sure how to set the Rng = to the appropriate cell range.
 
Upvote 0

Forum statistics

Threads
1,206,921
Messages
6,075,586
Members
446,147
Latest member
homedecortips

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