|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub ykcbf() '//2025.3.28 快速删除空行
- Application.ScreenUpdating = False
- Application.Calculation = xlCalculationManual
- Dim tm: tm = Timer
- With ActiveSheet
- r = .UsedRange.Find("*", , -4163, , 1, 2).Row
- Set Rng = Nothing
- arr = .UsedRange
- For i = 2 To r
- If IsRowEmpty(.Rows(i)) Then
- If Rng Is Nothing Then
- Set Rng = .Rows(i)
- Else
- Set Rng = Union(Rng, .Rows(i))
- End If
- End If
- Next i
- If Not Rng Is Nothing Then Rng.Delete
- End With
- Application.ScreenUpdating = True
- Application.Calculation = xlCalculationAutomatic
- MsgBox "共用时:" & Format(Timer - tm, "0.000") & "秒!"
- End Sub
- Function IsRowEmpty(rowRange As Range) As Boolean
- Dim cell As Range
- Dim isBlank As Boolean
- isBlank = True
- For Each cell In rowRange.Cells
- If Trim(cell.Value) <> "" Then
- isBlank = False
- Exit For
- End If
- Next cell
- IsRowEmpty = isBlank
- End Function
复制代码
|
|