Rip*_*ter 4 excel vba excel-vba
我想在第1列中的数据更改时在行之间添加边框.这段代码打破了.LineStyle = xlContinuous.我得到的错误是"无法设置Border类的LineStyle属性".
代码中是否有错误或其他方法?
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
Run Code Online (Sandbox Code Playgroud)
它似乎xlEdgeBottom不仅仅是xlBottom.所以换行:
With .Borders(xlEdgeBottom)
至
With .Borders(xlBottom)
它对我有用