[英]How to clear data between first and last row in excel column
我需要清除excel列中第一個單元格和最后一個單元格之間的數據。 我嘗試了這段代碼,但它刪除了整張表中的數據,我只需要一個特定的列。
Sub DeleteRow()
Dim i1 As Long
Dim iMax As Long
iMax = Cells.SpecialCells(xlCellTypeLastCell).row
For i1 = iMax - 1 To 2 Step - 1
Rows(i1).EntireRow.Clear
Next i1
End Sub
這將清除A列中第一行和最后一行之間的內容。
Sub ClearRows()
Dim lastRow As Long
lastRow = Range("A" & Rows.Count).End(xlUp).Row
Range("A2:A" & lastRow - 1).ClearContents
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.