Sub DeleteRowsWithEmptyColumnD()
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long
' Set the worksheet where you want to delete rows
Set ws = ThisWorkbook.Sheets("Sheet1") ' Change "Sheet1" to your sheet's name
' Find the last used row in column D
lastRow = ws.Cells(ws.Rows.Count, "D").End(xlUp).Row
' Loop through rows in reverse order to avoid issues with row deletion
For i = lastRow To 2 Step -1
If IsEmpty(ws.Cells(i, "D")) Then
ws.Rows(i).Delete
End If
Next i
End Sub
今天要处理数据,需要用到excel。
记录下相关的VBA code,用于删除D列为空的行。
Similar Posts:
- None Found