Hello,
I am trying to apply Conditional formatting using VBA from an active cell location. I can't get it working no matter what I do.
I think I've narrowed down the problem to the bolded parts. If I have an actual cell address (C19) I can get it to work for a range starting with C19.
I need to be able to run the Conditional Format as part of a Sub. I have ActiveCell locations but the operator at the screen does not know the location to start.
This is what I have at the moment:
startCell = ActiveCell.Address(0, 0)
MsgBox startCell
ActiveCell.Resize(6, NumCavLines).Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=AND(LEN(TRIM(startCell))>0,OR(startCell>$L$6,startCell<$M$6))"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
I am trying to apply Conditional formatting using VBA from an active cell location. I can't get it working no matter what I do.
I think I've narrowed down the problem to the bolded parts. If I have an actual cell address (C19) I can get it to work for a range starting with C19.
I need to be able to run the Conditional Format as part of a Sub. I have ActiveCell locations but the operator at the screen does not know the location to start.
This is what I have at the moment:
startCell = ActiveCell.Address(0, 0)
MsgBox startCell
ActiveCell.Resize(6, NumCavLines).Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=AND(LEN(TRIM(startCell))>0,OR(startCell>$L$6,startCell<$M$6))"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False