Jonmo1
MrExcel MVP
- Joined
- Oct 12, 2006
- Messages
- 44,061
This is strange,
If my active cell is NOT A1, the formula entered into conditional formatting is off. The range references get all messed up. For example, if my active cell is Say D5
Condition 1 is
=IT65533=IU65533
Condition 2 is
=IT65533<>IU65533
But if I run the code with A1 as my active cell, it gets entered correctly as
Condition 1
=A1=B1
Condition 2
=A1<>B1
Why does this happen ?
Thanks...
Code:
Sub Macro1()
With Range("A1")
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=A1=B1"
.FormatConditions(1).Interior.ColorIndex = 3
.FormatConditions.Add Type:=xlExpression, Formula1:="=A1<>B1"
.FormatConditions(2).Interior.ColorIndex = 50
.AutoFill Destination:=Range("A1:A29"), Type:=xlFillDefault
End With
End Sub
If my active cell is NOT A1, the formula entered into conditional formatting is off. The range references get all messed up. For example, if my active cell is Say D5
Condition 1 is
=IT65533=IU65533
Condition 2 is
=IT65533<>IU65533
But if I run the code with A1 as my active cell, it gets entered correctly as
Condition 1
=A1=B1
Condition 2
=A1<>B1
Why does this happen ?
Thanks...