I wish to compare two sheets [Sheet1 and Sheet2] within one workbook and format the second sheet conditionally, based on an exact match to the first sheet.
Cell by cell, I can add the specific conditional formatting rule to each cell but this is tedious and its hard to see where I have applied the conditional format and where not.
So I tried to construct a macro to apply to a range of cells.
I tried to assign the logical result of the compare test to a cell outside of the range[lets say on Sheet2, A1] , and then format the range cells based on that logical value. I think my error is in conditional format criterion but I am a bit stuck.
Many thanks in advance for your help!
HilaryP
Sheets("Sheet2").Select
' conditional format criterion
Range("A1").FormulaR1C1 = "=AND(Sheet1!R[1]C[1]= Sheet2!R[1]C[1])"
'
' format range based on logical result
Range("A2:J4").Select ' select range to format
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
Sheets("Sheet2").Range("A1").FormulaLocal
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent3 ' Accent3 is green, Accent2 is red
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Range("A1").Select
'
'Conditional Formatting Formulas Deletion
Range("A1").ClearContents
Bookmarks