2017-08-15 155 views
0
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自动填充。运行时错误'1004' - 对象'全局'的方法'范围'在VBA中失败

请让我知道你们的想法。

+1

一行:'范围( “B1”)自动填写目的地:=范围( “B1:B” &范围( “A1”)结束(xlDown).Row。 +1)' –

回答

1

它应该是:

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

谢谢你的工作! – studentofarkad

相关问题