Flux导出数据到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
为遍历所有工作表
上述方法不同于删除第一列的空白行。