Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Importing a csv file | Excel Discussion (Misc queries) | |||
Importing text file, only option to edit existing file | Excel Discussion (Misc queries) | |||
importing csv file | Excel Discussion (Misc queries) | |||
Importing File | Excel Programming | |||
Importing File | Excel Programming |