Need help in deleting specific data.

  • Thread starter Thread starter tweacle
  • Start date Start date
T

tweacle

Hi there
Can anyone help. I am looking for a macro or someway that I can delete
data out of a workbook that dont contain specific data. If in column E
it dont say one of the following Nhampton, euston, tring, bletchley,
Nhamp Emd, Nhamp NJ, Nhamptn RS, Watford Jn, Bltchly MD, Bedford,
Bletch CS or M keynes I need the row totally deleted.
This will be all the way down the workbook until the last entry.

Can anyone help.
 
Dont know if anyone can help me on this.
Ive managed to get a macro but its deleting the wrong way round.


Sub TRY()
Dim c As Range
Dim x(), j, fo As String
Dim i As Integer
x = Array("Nhampton", "euston", "tring", "bletchley", "Nhamp Emd"
"Nhamp NJ", "Nhamptn RS", "Watford Jn", "Bltchly MD", "Bedford"
"Bletch CS", "M keynes")
For i = LBound(x) To UBound(x)
Set c = Range("E:E").Find(x(i), LookIn:=xlValues, Lookat:=xlWhole)
If c Is Nothing Then GoTo nxt
fo = c.Address
Do Until j = fo
Set c = Range("E:E").FindNext(After:=c)
j = c.Address
Range(j).EntireRow.ClearContents
Loop
nxt:
Next
Range("E:E").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub

What im trying to do is where the data in column "E" says Northampto
etc as shown above I need to KEEP IT and not delete, but delet
everything else.
Just one other thing I forgot to mention was that if the cell is blan
in column E could the macro poss ignore this cell.

Thank
 

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