|
简单改了一下:- Sub 删除空行空列()
- Dim Area_ As Range
- Dim Rng1 As Range
- Dim Rng2 As Range
- Dim Ro As Long
- Dim Col As Integer
- Dim lstRo As Long
- Dim lstCol As Integer
- Set Area_ = ActiveSheet.UsedRange
- lstRo = Area_.Rows.Count
- lstCol = Area_.Columns.Count
- Application.ScreenUpdating = False
- For Ro = 1 To lstRo
- If Application.CountA(Area_.Rows(Ro)) = 0 Then
- If Rng1 Is Nothing Then
- Set Rng1 = Cells(Ro, 1)
- Else
- Set Rng1 = Union(Rng1, Cells(Ro, 1))
- End If
- End If
- Next
- For Col = 1 To lstCol
- If Application.CountA(Area_.Columns(Col)) = 0 Then
- If Rng2 Is Nothing Then
- Set Rng2 = Cells(1, Col)
- Else
- Set Rng2 = Union(Rng2, Cells(1, Col))
- End If
- End If
- Next
- Rng1.EntireRow.Delete
- Rng2.EntireColumn.Delete
- Set Area_ = Nothing
- Set Rng1 = Nothing
- Set Rng2 = Nothing
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|