Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FormatConditions border on a single edge

Tags:

excel

vba

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
like image 858
Ripster Avatar asked Jul 22 '13 21:07

Ripster


1 Answers

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

like image 62
chancea Avatar answered Nov 14 '22 22:11

chancea