View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Daniel.C Daniel.C is offline
external usenet poster
 
Posts: 43
Default Macro or VBA Code to return Multiple Rows?

You may open the text file in Excel and use a filter to do the job. if you
want a macro, use :

Sub test()
Dim myRange As Range, BeginRow As Long, EndRow As Long
BeginRow = [A:A].Find("EJ", after:=[A1]).Row
EndRow = [A:A].Find("EM", [A65000], , , xlColumns, xlPrevious).Row
Set myRange = Range("A" & BeginRow & ":D" & EndRow)
myRange.Select
End Sub

It is assumed that there are no contract ID betwenn EJ and EM. Othrwise, the
macro should be modified.
--
Regards.
Daniel
"TerryM" a écrit dans le message de news:
...
Here's my problem, I have a text file with over 7000+ rows and roughly 8
columns, out of all the rows I only need about 150 of the rows and only 4
of
the columns. The rows are sorted by Contract ID such as "AA", "BB" and so
on. What I need are the "EJ" and "EM" contracts, the problem is that the
amount of contracts change on a daily basis, one day there might be 45
"EJ"'s
and the next 61 of them.

Is there any Lookup or VBA code that I can do a lookup of the "EJ" and
"EM"
lines and have it return ALL of the lines so that I can then export into a
database. And before the question is asked I have already tried importing
it
directly into the database. It gets a "Internal Internet Failure" error.

Thank you for any assistance.