Home |
Search |
Today's Posts |
#1
|
|||
|
|||
VBA Conditional Formatting has mind of it's own!
I have the following code called by the Workbook_SheetCalculate event. It
works, however it seems to have a mind of it's own. When I check the conditonal format of Cell G2 it reads =AND($H3="",$G3<=TODAY()). It should read H2 & G2. I don't understadn what is causing this, however I could adjust my code to offset by one. But then othertimes the numbers are way off. What am I doing wrong that Excel won't start at G2 and autofill down incrementing as needed For Each Sh In ThisWorkbook.Worksheets shLast = LastRow(Sh) With Sh.Range("G2:G" & shLast) .FormatConditions.Delete .FormatConditions.Add Type:=xlExpression, Formula1:="=AND($H2="""",$G2<=TODAY())" .FormatConditions(1).Font.Bold = True .FormatConditions(1).Font.ColorIndex = 3 End With Next Function LastRow(Sh As Worksheet) 'Courtesy of www.contextures.com LastRow = Sh.Cells.Find(What:="*", _ After:=Sh.Range("A1"), _ lookat:=xlPart, _ LookIn:=xlFormulas, _ searchorder:=xlByRows, _ searchdirection:=xlPrevious, _ MatchCase:=False).Row End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Conditional Formatting Error | Excel Worksheet Functions | |||
difficulty with conditional formatting | Excel Discussion (Misc queries) | |||
conditional formatting question | Excel Discussion (Misc queries) | |||
Determine cells that drive conditional formatting? | Excel Discussion (Misc queries) | |||
Conditional formatting not available in Excel | Excel Discussion (Misc queries) |