运行时错误'''与边界

时间:2014-11-03 01:10:04

标签: excel vba

我有以下代码,符合罚款。 但是当它运行时,它会添加细边框,但粗边框会给我Run-time 438 error

 Border = ActiveSheet.Range("A" & ActiveSheet.Rows.Count).End(xlUp).Row
Range("A3:H" & Border).Select
    With Selection.Borders
        .LineStyle = xlContinuous
        .Weight = xlThin
        .ColorIndex = xlAutomatic
    End With

Range("A3:H" & Border).BorderAround_
    Weight = xlThick

我的目标是在所有细胞周围提供边界,然后在边缘周围设置一个粗边框。 任何帮助都会很棒。 谢谢!

1 个答案:

答案 0 :(得分:4)

问题在于BorderAround 方法Border 对象的语法风格之间的区别。 Weight参数是内部参数指定,而不是属性(我希望我能正确描述!)。

Dim border As Long
border = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
With Range("A3:H" & border).Borders
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = xlAutomatic
End With
Range("A3:H" & border).BorderAround Weight:=xlThick

注意在将权重分配给BorderAround时使用冒号等于。