Thread: deleting rows
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default deleting rows

Hi childofthe1980s

See
http://www.rondebruin.nl/delete.htm

If you can check one column use the filter example (faster)
If not use the loop like this to check the whole row

Sub Example1()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

Firstrow = ActiveSheet.UsedRange.Cells(1).Row
Lastrow = ActiveSheet.UsedRange.Rows.Count + Firstrow - 1
With ActiveSheet
.DisplayPageBreaks = False
For Lrow = Lastrow To Firstrow Step -1
If Application.WorksheetFunction.CountIf(.Rows(Lrow), "Ending Balance") 0 Then .Rows(Lrow).Delete
' Delete each row if the value "Ending Balance" exist in the row (It will look in the whole row)
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub





--
Regards Ron de Bruin
http://www.rondebruin.nl


"childofthe1980s" wrote in message
...
Hello:

I have a huge spreadsheet of over 20,000 rows. I want to delete any row
that has a cell that contains the phrase "Ending Balance". Is there a way to
tell Excel to delete such rows, without my having to delete each of the rows
one by one?

If I manually delete these rows, it will take hours.

Thanks!

childofthe1980s