S
Scott R
Hi Guys im trying to delete empty rows with a macro using the following vba
however the rows have been copied from another sheet and pasted as values
that were from formulas so the 'empty' rows actually contain a lot of "0"'s.
the code im using only seems to delete rows with nothing in the row at all.
is there a way to tell the macro to delete rows that have zeros in them?
Thanks heaps
scott
Sub Example2()
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView
With ActiveSheet
.DisplayPageBreaks = False
StartRow = 2
EndRow = 253
For Lrow = EndRow To StartRow Step -1
If Application.CountA(.Rows(Lrow)) = 0 Then .Rows(Lrow).delete
'This will delete the row if the whole row is empty (all columns)
Next
End With
ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub
however the rows have been copied from another sheet and pasted as values
that were from formulas so the 'empty' rows actually contain a lot of "0"'s.
the code im using only seems to delete rows with nothing in the row at all.
is there a way to tell the macro to delete rows that have zeros in them?
Thanks heaps
scott
Sub Example2()
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView
With ActiveSheet
.DisplayPageBreaks = False
StartRow = 2
EndRow = 253
For Lrow = EndRow To StartRow Step -1
If Application.CountA(.Rows(Lrow)) = 0 Then .Rows(Lrow).delete
'This will delete the row if the whole row is empty (all columns)
Next
End With
ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub