Conditional Formatting formula - change to offset method (1 Viewer)

Rx_

Nothing In Moderation
Local time
Yesterday, 17:28
Joined
Oct 22, 2009
Messages
2,803
The following works to add a conditional format.
The Date in Column J will turn green if the number in Column K is greater than 1.
The imported data from MSAccess starts on Row 6 and can have different amounts of rows depending on the query.

This code works. Just wondering if anyone knows how to use the Offset method? It is the line commented out.
I might want to put a variable in there to make my formula more universal.

Code:
Sub RxConditionalFormat()
With Sheets(1)
        Application.Goto .Range("J6")
With .Range("J6:J" & .Range("A" & .Rows.Count).End(xlUp).Row)
            .FormatConditions.Delete
            .FormatConditions.Add Type:=xlExpression, Formula1:="=K6>1"
            '.FormatConditions.Add Type:=xlExpression, Formula1:="=ActiveCell.Offset(-1, 0) > 1"
    With Selection.FormatConditions(1).Font
        .ThemeColor = xlThemeColorAccent3
        .TintAndShade = -0.249946592608417
    End With
            .FormatConditions(1).StopIfTrue = True
        End With
End With
End Sub
 

Rx_

Nothing In Moderation
Local time
Yesterday, 17:28
Joined
Oct 22, 2009
Messages
2,803
Follow up: The commented out offset method.
Got a response from the Mr. Excel web site on how to enter the code in the commented section. However, it didn't work the same.
Instead of hard-coded column names, replaced them with variables.

Just wanted to note that on data sheets with thousand to 40 thousand records
Where this is running multiple times on various columns, this runs extremely fast!
If an Access application with Excel automation is creating many reports - this method would be worth trying.
 

Users who are viewing this thread

Top Bottom