Sub 删除空行() '删除空行或只有空格的行 Application.ScreenUpdating = False Dim fl As Range Dim arr, arr0 Dim k& Dim lr&, lc% Set fl = Cells.Find("*", , , , xlByColumns, xlPrevious) '查最大列 lc = fl.Column Set fl = Cells.Find("*", , , , xlByRows, xlPrevious) '查最大行 lr = fl.Row arr = Range(Cells(1, 1), Cells(lr, lc)).Value For k = UBound(arr) To 1 Step -1 arr0 = Split(Join(Application.Index(arr, k), ""), " ") If UBound(arr0) <> 0 Then Rows(k).Delete Next k Application.ScreenUpdating = True End Sub Sub 删除空列() '删除空列或只有空格的列 Application.ScreenUpdating = False Dim fl As Range Dim arr, arr0 Dim l% Dim lr&, lc% Set fl = Cells.Find("*", , , , xlByColumns, xlPrevious) '查最大列 lc = fl.Column Set fl = Cells.Find("*", , , , xlByRows, xlPrevious) '查最大行 lr = fl.Row arr = Range(Cells(1, 1), Cells(lr, lc)).Value For l = UBound(arr, 2) To 1 Step -1 arr0 = Split(Join(Application.Transpose(Application.Index(arr, , l)), ""), " ") If UBound(arr0) <> 0 Then Columns(l).Delete Next l Application.ScreenUpdating = True End Sub
|