Thread: Delete rows
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Delete rows

Sub delete_zero_rows()
Dim c As Range
With ActiveSheet.Columns("H")
Do
Set c = .Find("0", LookIn:=xlValues, lookat:=xlWhole, _
MatchCase:=False)
If c Is Nothing Then Exit Do
c.EntireRow.Delete
Loop
End With
End Sub

If you're not familiar with VBA and macros, see David McRitchie's site for
more on "getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

or Ron de De Bruin's site on where to store macros.

http://www.rondebruin.nl/code.htm

In the meantime..........

First...create a backup copy of your original workbook.

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + r to open Project Explorer.

Find your workbook/project and select it.

Right-click and InsertModule. Paste the code in there. Save the
workbook and hit ALT + Q to return to your workbook.

Run or edit the macro by going to ToolMacroMacros.

You can also assign this macro to a button or a shortcut key combo.


Gord Dibben MS Excel MVP

On Mon, 4 Aug 2008 09:58:02 -0700, Koz
wrote:

I am trying to delete all rows where the value of one of the cells equals
zero, I have received macros but I have no idea what I am doing! Pasting
them into the sheet causes an error message stating Next without For. I am
using Excel 2000 SR-1 Professional. The cell I am trying to compare to zero
is in row H. The file has been imported from Quickbooks and is supposed to be
used to do a physical inventory.