![](/img/trans.png)
[英]Excel VBA - Error in code to copy to specific sheet, dependent on range
[英]vba code for excel range on other sheet
我嘗試使用下面的VBA代碼刪除其他工作表上的一系列數據,但它刪除了sheet1上的數據。 有人可以幫忙嗎?
With Sheets("Found")
lr = .Range("A" & Rows.Count).End(xlUp).Row
Range(Cells(2, 1), Cells(lr, 5)).Clear
End With
謝謝
放一段。
With Sheets("Found")
lr = .Range("A" & Rows.Count).End(xlUp).Row
.Range(.Cells(2, 1), .Cells(lr, 5)).Clear
End With
引用工作表對象時的小錯字。
在第3行,您沒有將Range與Sheets("Found")
關聯,因為您缺少.
在Range(Cells(2, 1), cELLS(LR, 5)).Clear
。
應該看起來像這樣:
With Sheets("Found")
lr = .Range("A" & .Rows.Count).End(xlUp).Row
.Range(.Cells(2, 1), .Cells(lr, 5)).Clear
End With
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.