2017-08-15 92 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

相關問題