S
slc
Need expert advice on this. I want to create a macro to draw
separator line between category using conditional formatting (CF). I
a simple example below, I want to create a separator (bottom) line a
A2, A3 and A4 i.e to separate Item X, Y and Z. E.g. the conditiona
formatting formula for
In cell A2, CF formula: if $A2<>$A3, then draw bottom line.
In cell A3, CF formula: if $A3<>$A4, then draw bottom line.
and so on...
A
1 X
2 X
3 Y
4 Z
Tried with the macro below but always have error (Error 5: Invali
Procedure or Call) in the statement:
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$"
ActiveCell.Value & "<>$" & NextCell.Value
Thanks.
---------
Sub CreateDownBorder()
' If the current cell value not equat to the next cell/row value
create a separator.
Set NextCell = ActiveCell.Offset(1, 0)
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$"
ActiveCell.Value & "<>$" & NextCell.Value
'
With Selection.FormatConditions(1).Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 5
End With
'
End Sub
:
separator line between category using conditional formatting (CF). I
a simple example below, I want to create a separator (bottom) line a
A2, A3 and A4 i.e to separate Item X, Y and Z. E.g. the conditiona
formatting formula for
In cell A2, CF formula: if $A2<>$A3, then draw bottom line.
In cell A3, CF formula: if $A3<>$A4, then draw bottom line.
and so on...
A
1 X
2 X
3 Y
4 Z
Tried with the macro below but always have error (Error 5: Invali
Procedure or Call) in the statement:
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$"
ActiveCell.Value & "<>$" & NextCell.Value
Thanks.
---------
Sub CreateDownBorder()
' If the current cell value not equat to the next cell/row value
create a separator.
Set NextCell = ActiveCell.Offset(1, 0)
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$"
ActiveCell.Value & "<>$" & NextCell.Value
'
With Selection.FormatConditions(1).Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 5
End With
'
End Sub
: