I am trying to add a border between rows when the data in column 1 changes. This code breaks at .LineStyle = xlContinuous
. The error I get is "Unable to set the LineStyle property of the Border class".
Is there an error in the code or an alternate way of doing this?
Sub AddBorders()
With Range("A:B").FormatConditions.Add(Type:=xlExpression, Formula1:="=A1<>A2")
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThin
End With
End With
End Sub
It seems that it is not xlEdgeBottom
it is just xlBottom
. So change the line:
With .Borders(xlEdgeBottom)
to
With .Borders(xlBottom)
and it worked for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With