把这段代码放在模块里面,运行这段代码
Sub 删除空行()
Dim rCount As Long
Dim i As Integer
Dim Lentemp As Long
With Application.VBE.ActiveCodePane.CodeModule
rCount = .CountOfLines
For i = rCount To 1 Step -1
Lentemp = Len(.Lines(i, 1))
Lentemp = Len(Trim(.Lines(i, 1)))
If Lentemp = 0 Then
.DeleteLines i
End If
Next i
End With
End Sub