Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default import txt files with more than 256 col and other tips

I need to import a txt file, that contains a large number of columns
(separated by TAB) ,as follows:
1)jump the first two lines of *.txt
2)columns widths are [10 10 10 10 10 19 15....(from this
point =15 for every column)
3)import columns from 1 to 240 in sheet1
import columns from 241 to 276 in sheet2
...and so on

I search throgh google and NG reading a lot of suggestion, but still I can't
do this (important) thing...:-(

hoping this could help, here are the 3rd line of txt files (from whic I need
to do import)

0,000028 0,000032 0,000047 0,000095 0 0,00000838 0,00000052 0,00000319


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default import txt files with more than 256 col and other tips

If it is tab separated, then the column widths make no difference. Which is
it? fixed width, or tab delimited.

--
Regards,
Tom Ogilvy

"uriel78" wrote in message
...
I need to import a txt file, that contains a large number of columns
(separated by TAB) ,as follows:
1)jump the first two lines of *.txt
2)columns widths are [10 10 10 10 10 19 15....(from this
point =15 for every column)
3)import columns from 1 to 240 in sheet1
import columns from 241 to 276 in sheet2
...and so on

I search throgh google and NG reading a lot of suggestion, but still I

can't
do this (important) thing...:-(

hoping this could help, here are the 3rd line of txt files (from whic I

need
to do import)

0,000028 0,000032 0,000047 0,000095 0 0,00000838 0,00000052 0,00000319




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default import txt files with more than 256 col and other tips

Open the file using either excel's intrinsic file handling or use the
FileSystemObject if you prefer.

Reading the file one line at a time, split each line into an array
using Split()

dim v, x as integer, y as integer,s as integer, r as long

r=1

'open file

s=1
y=1
'read a line from the file
v=Split(theLine,vbTab)
for x=lbound(v) to ubound(v)
thisworkbook.sheets("Sheet" & s).cells(r,y).value=v(x)

if y240 then
y=0
s=s+1
end if
y=y+1
next x

r=r+1

'loop and read next line


totally untested.

Tim



"uriel78" wrote in message
...
I need to import a txt file, that contains a large number of
columns
(separated by TAB) ,as follows:
1)jump the first two lines of *.txt
2)columns widths are [10 10 10 10 10 19
15....(from this
point =15 for every column)
3)import columns from 1 to 240 in sheet1
import columns from 241 to 276 in sheet2
...and so on

I search throgh google and NG reading a lot of suggestion, but
still I

can't
do this (important) thing...:-(

hoping this could help, here are the 3rd line of txt files (from
whic I

need
to do import)

0,000028 0,000032 0,000047 0,000095 0 0,00000838 0,00000052
0,00000319






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default import txt files with more than 256 col and other tips

It seems to be a very good idea...but I'm totally a newbie with VBA and
programming...and so I can't complete the routine with the import and the
looping...maybe I could send you a sample of my txt file....(about 3Mb...?)


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default import txt files with more than 256 col and other tips

uriel,

If you still need help you can send a file (make the obvious changes
to my e-mail address). If it's 3MB then you should zip it first.

Tim.

PS. It helps when posting if you include at least part of the text of
the message you're replying to.


"uriel78" wrote in message
...
It seems to be a very good idea...but I'm totally a newbie with VBA
and
programming...and so I can't complete the routine with the import
and the
looping...maybe I could send you a sample of my txt file....(about
3Mb...?)






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default import txt files with more than 256 col and other tips

Thanks for your courtesy, I think I've found a little trick (See post below
in reply to Tom ) that solve my specific problem...:-))

If you want for your interest/research/curiosity I can send you the txt
file and my relative solution (a veryveryvery newbie solution)

Now I go and put my head into ice, 'cause it is burning...:-)

"Tim Williams" <saxifrax@pacbell*dot*net ha scritto nel messaggio
...
uriel,

If you still need help you can send a file (make the obvious changes
to my e-mail address). If it's 3MB then you should zip it first.

Tim.

PS. It helps when posting if you include at least part of the text of
the message you're replying to.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default import txt files with more than 256 col and other tips

sorry, fixed widht...



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default import txt files with more than 256 col and other tips

well, maybe I've found a way to bypass my trouble by using querytables.add
macro four times (each time for different intervals)
....but still have some questions about the possibility to use a dialog
window to browse for the input file instead of specifying it in the macro...
just open another 3ad for this question...


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default import txt files with more than 256 col and other tips

How does querytables solve the 256 column problem?

--
Regards,
Tom Ogilvy

"uriel78" wrote in message
...
well, maybe I've found a way to bypass my trouble by using querytables.add
macro four times (each time for different intervals)
...but still have some questions about the possibility to use a dialog
window to browse for the input file instead of specifying it in the

macro...
just open another 3ad for this question...




  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default import txt files with more than 256 col and other tips

It doesn't solve the problem itself in general, but in my case it works
fine...
My file text is subidived into columns that I can consider forming 4 groups.
I turn on Macro REcorder and then import the text file (Data-import)
choosing the first group of columns.
Then just take a look to the macro recorded and coy it three times.

So I run 4 times the query everytime changing TextFileColumnDataTypes
property by defining which columns to take...


ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\elab1.txt _
, Destination:=Range("A1"))
......
....
....
..TextFileColumnDataTypes =Array(...)


I think it's rather a newbie trick, but if I consider I'm working with VBA
only for 3days in my life...it should be more than nothing....:-)




  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default import txt files with more than 256 col and other tips

ehm...I hope you're an excel guru :-)....can you take a look to my other
post "Definition of a statistical function..."

I'm struggling with it...:-//


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
Import Several .txt Files Renee B. Excel Discussion (Misc queries) 2 October 3rd 07 07:06 PM
Import files on a mac Andreas Roschger Excel Programming 5 February 1st 05 12:43 AM
import files Hollis Excel Programming 2 November 29th 04 08:27 PM
Import and Rename Files rickey24[_7_] Excel Programming 1 July 7th 04 02:43 AM
Import multiple files macro can't find files Steven Rosenberg Excel Programming 1 August 7th 03 01:47 AM


All times are GMT +1. The time now is 10:23 PM.

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

About Us

"It's about Microsoft Excel"