-3

当我运行这个 VBA 代码时,我得到一个错误。

Option Explicit
Sub CreateBorder()
ActiveCell.CurrentRegion.BorderAround
LineStyle:=xlDot, Weight:=xlThick, Color=RGB(255,0,0)
End Sub

该错误似乎出现在 Sub CreateBorder() 行中。问题是什么?

4

1 回答 1

4

有两个问题:

  • 您不能将语句拆分为两行(除非您_在第一行末尾使用 a)
  • 参数名称后面需要跟:=(你使用Color=...

所以它可以是:

ActiveCell.CurrentRegion.BorderAround LineStyle:=xlDot, Weight:=xlThick, Color:=RGB(255, 0, 0)

或者

ActiveCell.CurrentRegion.BorderAround _
        LineStyle:=xlDot, Weight:=xlThick, Color:=RGB(255, 0, 0)
于 2013-05-20T17:23:54.640 回答