View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default a Macro for importing & parsing text?

I would use only Start and end. Have the data include where it is suppose to
go. Here is some code that may help.

start,Sheet2,A5
your data


end


Const Start_State = 1
Const Data_State = 2

State = Start_State
Do While tsread.atendofstream = False

InputLine = tsread.ReadLine
select case State

Case Start_State
if Left(InputLine,5) = "Start" then
'your code here to get worksheet name and start range
State = Data_State
end if
Case Data_State
if Left(InputLine,3) = "End" then
Data_Start = Start_State
else
'your code here to extract data
end select


"DBme" wrote:

I have a system that creates a delimited text file that I can import into
Excel using the "get external data from text file" option and ... after
answering all the question, imports just fine.

The problem is that this text file contains 160 different sections that have
to be imported into Excel into 160 different locations, so the job becomes
ponderous.

Since I have some control over the input text (as long as it stays text) I
could add any kind of "section_1_starts_here" and/or "section_1_ends_here"
markers in the text.

My questions are 1) Can a macro be created to import this data and 2) how
complex/intelligent would that Macro have to be?