Flux導(dǎo)出數(shù)據(jù)到excel后蹄葱,存在很多空白行螟凭,刪除方法如下:
Sub DeleteEmptyRows()
Dim sh As Worksheet
For Each sh In ThisWorkbook.Sheets
sh.Select
Dim LastRow As Long, r As Long
LastRow = ActiveSheet.UsedRange.Rows.Count
LastRow = LastRow + ActiveSheet.UsedRange.Row - 1
For r = LastRow To 1 Step -1
If WorksheetFunction.CountA(Rows(r)) = 0 Then Rows(r).Delete
Next r
Next
End Sub
其中
Dim sh As Worksheet
For Each sh In ThisWorkbook.Sheets
sh.Select #選中工作表
……
Next
為遍歷所有工作表
上述方法不同于刪除第一列的空白行。