Thread: delete rows
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
RichardSchollar[_2_] RichardSchollar[_2_] is offline
external usenet poster
 
Posts: 76
Default delete rows

Hi Ivor

If you have a lot of rows (ie into the 1000s) then using autofilter
will increase the spped of execution considerably over looping:

Sub RemoveBlanks()
Dim r As Range
Set r = Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row) 'spec the
range to run from A1 to the last row
'note that presumed header in row 1. Change "A" column to the actual
column
With r
.AutoFilter field:=1, Criteria1:="=" 'filter range for blanks
.Offset(1).EntireRow.Delete 'offset so don't delete header row
(only visible cells will be deleted)
.AutoFilter 'turn off autofilter
End With
End Sub

Best regards

Richard


On Dec 29, 3:11 pm, "Ivor Williams" wrote:
I've a spreadsheet of inventory information that was exported from
QuickBooks. The resulting spreadsheet contains a number of rows with no
information in the column I want to sort on, so I would like to
automatically delete those rows. I'm totally new to writing VBA for Excel,
but I'm quite comfortable with it in Access, so understand it somewhat. I
also understand I can modify the QuickBooks report so the spreadsheet is
created in a format that will work, but I would like some assistance with
the code so I can start to learn what I'm doing in Excel.

Thanks,
Ivor