文件名称:excel vba 删除空余行和列
文件大小:8KB
文件格式:XLSX
更新时间:2021-06-06 09:43:09
excel vba
删除空余行: 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 删除空余列: Dim LastColumn As Long, c As Long LastColumn = ActiveSheet.UsedRange.Columns.Count LastColumn = LastColumn + ActiveSheet.UsedRange.Column For c = LastColumn To 1 Step -1 If WorksheetFunction.CountA(Columns(c)) = 0 Then Columns(c).Delete Next c