Excel 删除多余的空行(VBA)

Option Explicit

Public Sub DeleteBlankEntireRowDemo()

Dim RowID As Integer
Dim sMessage As String

‘ * 错误源
Dim sSource As String
On Error GoTo Err_Handler

For RowID = Range(Cells(1, 1), ActiveSheet.UsedRange).Rows.Count To 1 Step -1
If Application.WorksheetFunction.CountBlank(Rows(RowID).EntireRow) = 256 Then Rows(RowID).Delete
Next

Exit_Label:
On Error GoTo 0

Exit Sub
Err_Handler:
sMessage = “运行出错!” & vbCrLf _
& Err.Description

‘ * 显示友好的错误信息
Call MsgBox( _
Prompt:=sMessage, _
Buttons:=vbExclamation)

GoTo Exit_Label

End Sub

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理

相关文章

开始在上面输入您的搜索词,然后按回车进行搜索。按ESC取消。

返回顶部