[英]How to clear data between first and last row in excel column
I need to clear data between first cell and last cell in a excel column. 我需要清除excel列中第一个单元格和最后一个单元格之间的数据。 I tried this code, but it deletes the data from the entire sheet, I need only for a specific column.
我尝试了这段代码,但它删除了整张表中的数据,我只需要一个特定的列。
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
This would clear content between the first row and the last row in column A. 这将清除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.