Row Deletion

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

I am trying to create a macro that looks at all the data
from row 26 down and using data in column D if it does not
equal DR* or DB* delete the row.

End result all rows below 26 are deleted leaving DR* and
DB*.
 
it is possible with a automatic filter !!!
filter with db*



--
....Patrick
Quoi que vous fassiez, faites le bien .
Mail: http://cerbermail.com/?KPW0tTCjFw
Connectez vous sur ce forum par :
news://msnews.microsoft.com/microsoft.public.fr.excel
 
Hi Dan;

You can use the following;


Sub try()
'selects the first cell you want to look at
Range("A27").Select

'loop through the rows until it hits an empty cell
While Not ActiveCell = ""

If Not ActiveCell.Offset(0, 3) = "DR*" And _
Not ActiveCell.Offset(0, 3) = "DB*" Then
'if its is not one of the two desired
'values then delete the row
Application.DisplayAlerts = False
ActiveCell.EntireRow.Delete
End If
ActiveCell.Offset(1, 0).Select
Wend

End Sub
 
something like this from the bottom up. I did not test but you get the idea
for i = cells(rows.count,"d").end(xlup).row to 26 step -1
if cells(i,"d")<> "DR*" and cells(i,"d")<>"DB*" then
cells(i,"d").entirerow.delete
next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top