Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Importing a file

To start, I am a novice at VBA.

Tyring to import files that are automatic file gernated from another
application (txt type
file). I want to import the first x lines - the header of the file - in a
"Delimited" format. The rest of the file I want to import just under the
imported header in a "Fixed Width" format. The file name will continually
vary and so will the location (I already have created code to compensate for
the file name and location).

The file will vary in lenght (which I have code to compensate for multiple
worksheets).

Now while importing the "data" portion of the file, on a line by line basis,
I need to execute additional functions (lookup type information) to another
file to decode the information.

Unfortunately, with my limited knowledge of VBA, I am doing this in small
steps and hopefully put it all together in the end - not the best way but I
can always optimize once I get it to work and learn more.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Importing a file

Dan,
Does you text data have some kind of Sequence number ?
If so, you could use SQL to import the records onto each WS with:
SELECT * FROM MytextFile WHERE SEQ<65500
And for WS(2):
SELECT * FROM MytextFile WHERE SEQ65500 AND SEQ<65500*2
Depending on all your data/processing, you may be able to use SQL functions
and/or JOINS.
You can fix the headers prior to querying the text file.
(I don't think the text driver supports LIMIT, so you need to rely on data
in the text file)

If not the above is not possible, then I guess you are stuck with a line by
line approach
Open MyFile For Output as #FreeFile
'read and process header
Do while not EOF(#FreeFile)
'read and process each line
Loop
etc

Depending on what your "additional functions (lookup type information)"
means, it may be easier to let Excel do that for you after the import.

There's nothing wrong with splitting your up into small step; each step does
a discrete of the processing.
Show us (the basics) of what you have so far and which parts you need help
with.

NickHK

"Dan" wrote in message
...
To start, I am a novice at VBA.

Tyring to import files that are automatic file gernated from another
application (txt type
file). I want to import the first x lines - the header of the file - in a
"Delimited" format. The rest of the file I want to import just under the
imported header in a "Fixed Width" format. The file name will continually
vary and so will the location (I already have created code to compensate

for
the file name and location).

The file will vary in lenght (which I have code to compensate for multiple
worksheets).

Now while importing the "data" portion of the file, on a line by line

basis,
I need to execute additional functions (lookup type information) to

another
file to decode the information.

Unfortunately, with my limited knowledge of VBA, I am doing this in small
steps and hopefully put it all together in the end - not the best way but

I
can always optimize once I get it to work and learn more.

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Importing a file

Unfortunately the file is not sequenced. I will try your suggestion then post
what I have (working or not) for some feedback.

Thanks

"NickHK" wrote:

Dan,
Does you text data have some kind of Sequence number ?
If so, you could use SQL to import the records onto each WS with:
SELECT * FROM MytextFile WHERE SEQ<65500
And for WS(2):
SELECT * FROM MytextFile WHERE SEQ65500 AND SEQ<65500*2
Depending on all your data/processing, you may be able to use SQL functions
and/or JOINS.
You can fix the headers prior to querying the text file.
(I don't think the text driver supports LIMIT, so you need to rely on data
in the text file)

If not the above is not possible, then I guess you are stuck with a line by
line approach
Open MyFile For Output as #FreeFile
'read and process header
Do while not EOF(#FreeFile)
'read and process each line
Loop
etc

Depending on what your "additional functions (lookup type information)"
means, it may be easier to let Excel do that for you after the import.

There's nothing wrong with splitting your up into small step; each step does
a discrete of the processing.
Show us (the basics) of what you have so far and which parts you need help
with.

NickHK

"Dan" wrote in message
...
To start, I am a novice at VBA.

Tyring to import files that are automatic file gernated from another
application (txt type
file). I want to import the first x lines - the header of the file - in a
"Delimited" format. The rest of the file I want to import just under the
imported header in a "Fixed Width" format. The file name will continually
vary and so will the location (I already have created code to compensate

for
the file name and location).

The file will vary in lenght (which I have code to compensate for multiple
worksheets).

Now while importing the "data" portion of the file, on a line by line

basis,
I need to execute additional functions (lookup type information) to

another
file to decode the information.

Unfortunately, with my limited knowledge of VBA, I am doing this in small
steps and hopefully put it all together in the end - not the best way but

I
can always optimize once I get it to work and learn more.

Thanks




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing a csv file Excel user Excel Discussion (Misc queries) 1 June 21st 06 09:19 PM
Importing text file, only option to edit existing file smokey99 Excel Discussion (Misc queries) 8 April 26th 06 09:08 PM
importing csv file godzooky Excel Discussion (Misc queries) 2 March 13th 06 09:12 PM
Importing File infojmac[_10_] Excel Programming 0 October 25th 04 02:30 PM
Importing File infojmac[_9_] Excel Programming 2 October 25th 04 02:15 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"