运行时错误'1004' – 对象'Global'的方法'Range'在VBA中失败

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") 

任何人都可以帮我,为什么我一直得到这个错误? 我设置的variables等于最后一个单元格的范围,但一列。 所以如果A列的范围是A55,lastcellex就是B55。 我正试图从B1:B55自动填充。

请让我知道你们的想法。

它应该是:

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