Selection.AutoFill Destination:=范围错误

时间:2017-04-13 12:29:47

标签: excel vba excel-vba

我无法使上述代码生效。我正在尝试为存储范围的两个不同变量运行选择自动填充宏,并且遇到错误。任何帮助都会很棒!

Sub Automation_BOBJ()

Dim startPointBobjGL As Range
Dim bobjGLNextCell As Range
Dim bobjGLLastCell As Range

Set startPointBobjGL = Range("A3")
Set bobjGLNextCell = startPointBobjGL.End(xlToRight).Offset(0, 1)
Set bobjGLLastCell = startPointBobjGL.End(xlToRight).Offset(13, 1)

bobjGLNextCell.FormulaR1C1 = "=VLOOKUP(RC[-4],R2C2:R27C15,(MONTH(TODAY())+1),0)"

Selection.AutoFill Destination:=Range(startPointBobjGL, bobjGLLast), Type:=xlFillDefault

ActiveCell.FormulaR1C1 = "103100335.7"

End Sub

2 个答案:

答案 0 :(得分:0)

我想它应该是这样的......

bobjGLNextCell.AutoFill Destination:=Range(bobjGLNextCell, bobjGLLastCell), Type:=xlFillDefault

答案 1 :(得分:0)

您应该添加以下内容:

Set startPointBobjGL = Sheets("Sheet").Range("A3")