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

How can I limit the number of lines when importing a file? Limit the import
to the first 53 lines of a file that has 50,000+ lines.

Want to import the first "XX" set of lines, then I want to skip a set of
lines, then continue to import the rest of the lines. The second import needs
to be inserted 2 or 3 lines down from the first import.

There is the function:

Workbooks.OpenText Filename:=

But it only has a StartRow and can not specify the "EndRow". Also can not
specify where to start in the worksheet, i.e. Cell A5

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,081
Default Importing a file

You can accomplish what you want by writing VBA code, or by manually changing
the data layout after it has been imported.

"Dan" wrote:

How can I limit the number of lines when importing a file? Limit the import
to the first 53 lines of a file that has 50,000+ lines.

Want to import the first "XX" set of lines, then I want to skip a set of
lines, then continue to import the rest of the lines. The second import needs
to be inserted 2 or 3 lines down from the first import.

There is the function:

Workbooks.OpenText Filename:=

But it only has a StartRow and can not specify the "EndRow". Also can not
specify where to start in the worksheet, i.e. Cell A5

Thanks

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

That is exactly what I am trying to achieve. Any input on how the code should
look is appreciated.

"Duke Carey" wrote:

You can accomplish what you want by writing VBA code, or by manually changing
the data layout after it has been imported.

"Dan" wrote:

How can I limit the number of lines when importing a file? Limit the import
to the first 53 lines of a file that has 50,000+ lines.

Want to import the first "XX" set of lines, then I want to skip a set of
lines, then continue to import the rest of the lines. The second import needs
to be inserted 2 or 3 lines down from the first import.

There is the function:

Workbooks.OpenText Filename:=

But it only has a StartRow and can not specify the "EndRow". Also can not
specify where to start in the worksheet, i.e. Cell A5

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,081
Default Importing a file

There are any number of approaches. Too suggest a reasonably efficient route
would require some knowledge of:

1) Your proficiency with VBA
2) the type of file (CSV, fixed width, tab delimited, etc) and its size (#
of lines)
3) whether you need to be able to use multiple text files or if it is always
going to be the same file name and in the same location.

Beyond that, you treat the file as a textstream object, use the Readline
method to iterate through each line in the file, parse each line using the
split method (assuming it is delimited), put the parsed values into cells

While not a difficult task, it isn't trivial for a VBA novice.

"Dan" wrote:

That is exactly what I am trying to achieve. Any input on how the code should
look is appreciated.

"Duke Carey" wrote:

You can accomplish what you want by writing VBA code, or by manually changing
the data layout after it has been imported.

"Dan" wrote:

How can I limit the number of lines when importing a file? Limit the import
to the first 53 lines of a file that has 50,000+ lines.

Want to import the first "XX" set of lines, then I want to skip a set of
lines, then continue to import the rest of the lines. The second import needs
to be inserted 2 or 3 lines down from the first import.

There is the function:

Workbooks.OpenText Filename:=

But it only has a StartRow and can not specify the "EndRow". Also can not
specify where to start in the worksheet, i.e. Cell A5

Thanks

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

To start, I am a novice at VBA.

To answer your questions:
The file is an 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.

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.


"Duke Carey" wrote:

There are any number of approaches. Too suggest a reasonably efficient route
would require some knowledge of:

1) Your proficiency with VBA
2) the type of file (CSV, fixed width, tab delimited, etc) and its size (#
of lines)
3) whether you need to be able to use multiple text files or if it is always
going to be the same file name and in the same location.

Beyond that, you treat the file as a textstream object, use the Readline
method to iterate through each line in the file, parse each line using the
split method (assuming it is delimited), put the parsed values into cells

While not a difficult task, it isn't trivial for a VBA novice.

"Dan" wrote:

That is exactly what I am trying to achieve. Any input on how the code should
look is appreciated.

"Duke Carey" wrote:

You can accomplish what you want by writing VBA code, or by manually changing
the data layout after it has been imported.

"Dan" wrote:

How can I limit the number of lines when importing a file? Limit the import
to the first 53 lines of a file that has 50,000+ lines.

Want to import the first "XX" set of lines, then I want to skip a set of
lines, then continue to import the rest of the lines. The second import needs
to be inserted 2 or 3 lines down from the first import.

There is the function:

Workbooks.OpenText Filename:=

But it only has a StartRow and can not specify the "EndRow". Also can not
specify where to start in the worksheet, i.e. Cell A5

Thanks



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,081
Default Importing a file

Dan - I suggest you break this down into its basic parts and post questions
about each over in the Programming newsgroup.

There are posters here who are excellent with VBA - but there is a better
focus in the other newsgroup.

"Dan" wrote:

To start, I am a novice at VBA.

To answer your questions:
The file is an 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.

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.


"Duke Carey" wrote:

There are any number of approaches. Too suggest a reasonably efficient route
would require some knowledge of:

1) Your proficiency with VBA
2) the type of file (CSV, fixed width, tab delimited, etc) and its size (#
of lines)
3) whether you need to be able to use multiple text files or if it is always
going to be the same file name and in the same location.

Beyond that, you treat the file as a textstream object, use the Readline
method to iterate through each line in the file, parse each line using the
split method (assuming it is delimited), put the parsed values into cells

While not a difficult task, it isn't trivial for a VBA novice.

"Dan" wrote:

That is exactly what I am trying to achieve. Any input on how the code should
look is appreciated.

"Duke Carey" wrote:

You can accomplish what you want by writing VBA code, or by manually changing
the data layout after it has been imported.

"Dan" wrote:

How can I limit the number of lines when importing a file? Limit the import
to the first 53 lines of a file that has 50,000+ lines.

Want to import the first "XX" set of lines, then I want to skip a set of
lines, then continue to import the rest of the lines. The second import needs
to be inserted 2 or 3 lines down from the first import.

There is the function:

Workbooks.OpenText Filename:=

But it only has a StartRow and can not specify the "EndRow". Also can not
specify where to start in the worksheet, i.e. Cell A5

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 MM:SS From Tab Delimited File and Charting Bryan Charts and Charting in Excel 4 July 28th 06 04:14 PM
Importing Text File Data into Excel where records span several row Razorback76 Excel Discussion (Misc queries) 2 June 25th 06 06:36 AM
Importing a csv file Excel user Excel Discussion (Misc queries) 1 June 21st 06 09:19 PM
importing csv file godzooky Excel Discussion (Misc queries) 2 March 13th 06 09:12 PM
Importing .txt data files increases .xls file size BrianJ Excel Discussion (Misc queries) 1 January 29th 05 02:02 PM


All times are GMT +1. The time now is 08:58 PM.

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"