View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Martin Fishlock Martin Fishlock is offline
external usenet poster
 
Posts: 694
Default delete rows using VB

Hi,

Try this macro.

Option Explicit

Sub deleterowswhereo0()

Dim ws As Worksheet
Dim lRowStart As Long, lRowEnd As Long, lRow As Long
Dim lColumn As Long

Application.ScreenUpdating = False

Set ws = ActiveSheet

lColumn = ws.Range("O1").Column
lRowStart = 15
lRowEnd = ws.UsedRange.Row + ws.UsedRange.Rows.Count - 1

For lRow = lRowEnd To lRowStart Step -1
If ws.Cells(lRow, lColumn).Value = 0 Then
ws.Rows(lRow).Delete
End If
Next lRow

Application.ScreenUpdating = True

End Sub

--
Hope this helps
Martin Fishlock
Please do not forget to rate this reply.


"cindee" wrote:

I know there's a million posts here on how to do this but since I'm such a
newbie, I don't know how to modify them to my explicit need.

I have a spreadsheet where I need to delete each ROW where the total in
Column O =0. I need to start the macro on Row 15 (due to headers) and need
it to extend to at least row 2500. I can't sort or modify the data at all
prior to running the macro.

Please send detailed instructions on how to put this into a macro...

thank you

~cr