本文介绍了单边上的FormatConditions边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当列1中的数据更改时,我试图在行之间添加边框.该代码在.LineStyle = xlContinuous
处中断.我得到的错误是无法设置Border类的LineStyle属性".
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
推荐答案
似乎不是xlEdgeBottom
而是xlBottom
.因此,更改行:
It seems that it is not xlEdgeBottom
it is just xlBottom
. So change the line:
With .Borders(xlEdgeBottom)
到
With .Borders(xlBottom)
对我有用
这篇关于单边上的FormatConditions边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!