View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Scott R Scott R is offline
external usenet poster
 
Posts: 54
Default Deleting rows (with zeros) with a macro

sorry if im a bit vague i dont use code that often but this will be a high
use workbook so definitely need code..
some rows will have data in them (which i want to keep) and others will only
a combination of zeros and blank cells (across columns A to AC) so i want to
be able to run a macro that will delete those rows to leave only the rows
that have data in them.

"Scott R" wrote:

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