View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
joel[_172_] joel[_172_] is offline
external usenet poster
 
Posts: 1
Default Speeding up a delete rows Macro


I don't know which posting to respond to. The quickest method of
deleteing rows is to add a formula into an auxillary column putt an X in
the column for row to delete. You can add the formula into row IV like
this


Sub Macro1()


Range("IV1").Formula = "=if(A1 5,X,Y)"

'then copy the formula down the entire
LastRow = Range("A" & Rows.Count).End(xlUp)
Range("IV1").Copy _
Destination:=Range("IV1:IV" & LastRow)

'Next replace formula in column IV with value
Range("IV1:IV" & LastRow).Copy
Range("IV1:IV" & LastRow).PasteSpecial Paste:=xlPasteValues


'Next sort on Row IV
Rows("1:" & LastRow).Sort _
header:=xlYes, _
key1:=Range("IV1"), _
Order:=xlAscending


'Now all you have to do is delete the X's.
'asume these is a header row
Columns("IV").AutoFilter
Columns("IV").AutoFilter Field:=1, Criteria1:="X"
Rows("2:" & LastRow).SpecialCells(Type:=xlCellTypeVisible).Del ete
Columns("IV").Delete
End Sub
this may seem like a lot of steps, but it is the quickest method


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=150619

Microsoft Office Help