【问题标题】:Run-time error '1004' - Method 'Range' of object'_Global' failed in VBA运行时错误“1004”-对象“_Global”的方法“范围”在 VBA 中失败
【发布时间】:2017-08-16 01:38:12
【问题描述】:
ActiveCell.FormulaR1C1 = "Y"
Range("B1").Select

Dim lastcellex As String

Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 1).Select

lastcellex = ActiveCell.Address
Range("B1").Select
Selection.AutoFill Destination:=Range("B1:lastcellex")

谁能帮助我了解为什么我不断收到此错误?我将变量设置为等于范围内的最后一个单元格,但超过一列。因此,如果 A 列中的范围是 A55,则 lastcellex 将是 B55。我正在尝试让它从 B1:B55 自动填充。

请让我知道你们的想法。

【问题讨论】:

  • 一行:Range("B1").AutoFill Destination:=Range("B1:B" & Range("A1").End(xlDown).Row+1)

标签: vba excel


【解决方案1】:

应该是:

Selection.AutoFill Destination:=Range("B1:" & lastcellex)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多