ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Need help in deleting specific data. (https://www.excelbanter.com/excel-worksheet-functions/156410-need-help-deleting-specific-data.html)

tweacle[_2_]

Need help in deleting specific data.
 

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.




--
tweacle

tweacle[_3_]

Need help in deleting specific data.
 

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).Entire Row.Delete
End Sub

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

Thanks




--
tweacle


All times are GMT +1. The time now is 03:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com