I agree with Ajax and ItsMe in that you do not need to import all data then delete the unwanted.
I would probably go the parse the text file route, but either will do the job.
Here's a sample using a txt file
Code:
'---------------------------------------------------------------------------------------
' Procedure : ImportText
' Author : mellon
' Date : 22/04/2015
' Purpose : Routine to take an input text file, parse it to find
' those records ending with "PE". For demo just output the records
' of interest to the immediate window.
'---------------------------------------------------------------------------------------
'
Sub ImportText()
Dim intFile As String 'variable to get freefile number
Dim strBuffer As String 'record within incoming file
Dim strFile As String 'incoming text file
10 On Error GoTo ImportText_Error
20 strFile = "C:\users\mellon\documents\TestDataPE.txt" ' Incoming file
30 intFile = FreeFile()
40 Open strFile For Input As #intFile
50 Do While EOF(intFile) = False
60 Line Input #intFile, strBuffer
70 Select Case Right(strBuffer, 2)
Case "PE"
' This is a row of interest to you...
'For demo -- just output the record of interest to the immediate window
80 Debug.Print "Keeper " & strBuffer
90 Case Else
' Ignore
100 End Select
110 Loop
120 Close #intFile
130 On Error GoTo 0
140 Exit Sub
ImportText_Error:
150 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ImportText of Module Q"
End Sub
Here is the sample output
Code:
Keeper 14,Miami, FL,2345PE
Keeper 922,Roanoke, VA,9550-PE
Keeper 3014,Brunswick, GA,w5337PE
Here is the sample txt file which is "C:\users\mellon\documents\TestDataPE.txt" on my computer.
Code:
CustomerId,City,State,ProductCode
10,Laredo, TX,12345TS
14,Miami, FL,2345PE
354,Orlando, FL,54995PF
922,Roanoke, VA,9550-PE
2941,Oswego, NY,44485-WD
3014,Brunswick, GA,w5337PE
Hope it's useful to you. Good luck.