View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default skip rows depending value of a particular cell in that row

The way of speeding up the code is to use an auxilary column putting a
character like 0 in the new column insteading of deleting the rows one at a
time. Then sort on the new column in descending order bringing all the 0's
to the top of the sorted area. Then deleting all the rows with zeroes.

Use this code
Sub test()
'Use column K as auxilary column
Lastrow = Range("A" & Rows.Count).End(xlUp).Row
Set SortRange = Range("A1:K" & Lastrow)
SortRange.Sort _
key1:=Range("K1"), _
order1:=xlDescending
Lastrow = Range("K" & Rows.Count).End(xlUp).Row
Rows("1:" & Lastrow).Delete

End Sub




"Prema" wrote:

I have a workbook with data elements in column A to F and about 1500 rows
(will increase). Column D sometime has the value "not assigned". I would like
to get subset of the data by leaving "not assigned" rows out. I have written
code to look at each from row 1 to end to check for "not assigned" in column
D and drop that row. It work but takes a while to run and as the file will be
getting larger with time it willl take longer.

Can anyone help with more efficient code?