lijiehao 当前离线
列兵
Dim Ex, Wb, Sht Set Ex = CreateObject("Excel.Application") Set Wb = Ex.Workbooks.Open("F:\test.xls") Set Sht = Wb.Sheets("Sheet1") '删除第2到第5行 Sht.Rows("2:5").Delete Ex.ActiveWorkbook.Save MsgBox "操作完成" Ex.Quit复制代码
TOP
DAIC 当前离线
中将
zhanglei1371 当前离线
六级士官
Sub DeleteEmptyRows() 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 End Sub复制代码