第1个回答 2015-10-27
可以删除选定区域内的空行
Private Sub Deleteblankrow()
On Error Resume Next
Dim rowindex As Long, columnindex As Long
Dim ifblank As Boolean
Dim actioncount As Long
Application.ScreenUpdating = False
For rowindex = 1 To selection.Rows.Count
For columnindex = 1 To selection.Columns.Count
If selection.Cells(rowindex, columnindex) <> "" Then
ifblank = False
Exit For
Else
ifblank = True
End If
Next columnindex
If actioncount >= selection.Rows.Count Then
Exit For
Else
If ifblank = True Then
selection.Rows(rowindex).EntireRow.Delete
rowindex = rowindex - 1
actioncount = actioncount + 1
End If
End If
Next rowindex
Application.ScreenUpdating = True
MsgBox "Mission complete", vbOKOnly, "Deleteblankrow"
End Sub