Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Import Text File

I need to write a macro to import a text file. The file is space delimited,
but has the last column on line 2. The file will look like this:

column1 column2 column3 column4 column5
column6
column1 column2 column3 column4 column5
column6

That 6th column will run almost the entire length of the previous 5. Is
there a way to import this as the 6th column instead of having it split from
the first line of data? Any help with this would be appreciated. Thank you!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Import Text File

If the total number of lines (including the column6 line) fit in a worksheet,
I'd just import the data and fix it after the import.

I'd put this in F1 (and drag down):
=IF(MOD(ROW(),2)=1,A2,NA())

Then select column F
edit|copy
Edit|paste special|Values

with column F still selected
edit|goto|special|Constants and uncheck Numbers, Text, Logicals--but leave
Errors checked)

Then rightclick on one of the selected N/A's and choose delete|entire row.



Jasmine wrote:

I need to write a macro to import a text file. The file is space delimited,
but has the last column on line 2. The file will look like this:

column1 column2 column3 column4 column5
column6
column1 column2 column3 column4 column5
column6

That 6th column will run almost the entire length of the previous 5. Is
there a way to import this as the 6th column instead of having it split from
the first line of data? Any help with this would be appreciated. Thank you!


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Import Text File

And to be totally honest, deleting the rows that have #n/a in them using this
technique may not work (if you have over 16k rows of data (8k separate areas).

You could sort the data by that column, then delete the #n/a rows pretty quickly
though.

And if the original sort order is important....

Add another helper column (column G???) and put:
=row()
and drag down
select column G
edit|copy
edit|paste special|values

Then sort your data by column F, delete the N/A's and resort by column G. (And
delete column G when you're done.)

Dave Peterson wrote:

If the total number of lines (including the column6 line) fit in a worksheet,
I'd just import the data and fix it after the import.

I'd put this in F1 (and drag down):
=IF(MOD(ROW(),2)=1,A2,NA())

Then select column F
edit|copy
Edit|paste special|Values

with column F still selected
edit|goto|special|Constants and uncheck Numbers, Text, Logicals--but leave
Errors checked)

Then rightclick on one of the selected N/A's and choose delete|entire row.

Jasmine wrote:

I need to write a macro to import a text file. The file is space delimited,
but has the last column on line 2. The file will look like this:

column1 column2 column3 column4 column5
column6
column1 column2 column3 column4 column5
column6

That 6th column will run almost the entire length of the previous 5. Is
there a way to import this as the 6th column instead of having it split from
the first line of data? Any help with this would be appreciated. Thank you!


--

Dave Peterson


--

Dave Peterson
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
Can I import text file of cash flow to excel file then use formula Bumpa Excel Discussion (Misc queries) 2 May 28th 10 04:22 PM
Would Like to Automate Batch File Creation and Text FIle Import socrtwo Excel Discussion (Misc queries) 2 August 18th 06 03:54 PM
How do I import text file, analyze data, export results, open next file Geoffro Excel Programming 2 March 6th 05 08:02 PM
Import text file into excel with preset file layout, delimeters VBA meldrape Excel Programming 7 June 15th 04 08:31 PM
Get External Data, Import Text File, File name problem Scott Riddle Excel Programming 1 July 11th 03 05:40 PM


All times are GMT +1. The time now is 11:35 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"