Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Nuc Nuc is offline
external usenet poster
 
Posts: 1
Default Input data from file to Excel in Column Format


Hey everyone I'm new to VB and need some help.

I'm trying to input a file from a .dat file (output from Fortran code).
The .dat file contains multiple column such as:
---------
2 5.48564954E+05 4.07889292E+06 5.47506020E+05 4.07922513E+06
3 5.48560812E+05 4.07880932E+06 5.47497497E+05 4.07914291E+06
4 5.48556669E+05 4.07872573E+06 5.47488975E+05 4.07906069E+06
5 5.48552526E+05 4.07864214E+06 5.47480453E+05 4.07897847E+06
6 5.48548383E+05 4.07855855E+06 5.47471931E+05 4.07889625E+06
7 5.48544240E+05 4.07847495E+06 5.47463408E+05 4.07881404E+06
8 5.48540097E+05 4.07839136E+06 5.47454886E+05 4.07873182E+06
9 5.48535954E+05 4.07830777E+06 5.47446364E+05 4.07864960E+06
10 5.48531811E+05 4.07822417E+06 5.47437842E+05 4.07856738E+06
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Input data from file to Excel in Column Format

Turn on the macro Recorder

Tools=Macros=Record a Macro

then open the file manually and go through the Text import wizard.

turn off the macro recorder.

You might have to rename the file to have a .txt extension to do it
manually, but I think it will work without that.

Now look at the recorded code.

Alter to suit your needs.

See help on the OpenText method.

--
Regards,
Tom Ogilvy


"Nuc" wrote in message
...

Hey everyone I'm new to VB and need some help.

I'm trying to input a file from a .dat file (output from Fortran code).
The .dat file contains multiple column such as:
---------
2 5.48564954E+05 4.07889292E+06 5.47506020E+05 4.07922513E+06
3 5.48560812E+05 4.07880932E+06 5.47497497E+05 4.07914291E+06
4 5.48556669E+05 4.07872573E+06 5.47488975E+05 4.07906069E+06
5 5.48552526E+05 4.07864214E+06 5.47480453E+05 4.07897847E+06
6 5.48548383E+05 4.07855855E+06 5.47471931E+05 4.07889625E+06
7 5.48544240E+05 4.07847495E+06 5.47463408E+05 4.07881404E+06
8 5.48540097E+05 4.07839136E+06 5.47454886E+05 4.07873182E+06
9 5.48535954E+05 4.07830777E+06 5.47446364E+05 4.07864960E+06
10 5.48531811E+05 4.07822417E+06 5.47437842E+05 4.07856738E+06



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Input data from file to Excel in Column Format


What about using an open statement such as:

'Open "file.dat" For Input As #1 'Open file for input to worksheet
'For i = 1 To ??
'Line Input #1, commandline
'Worksheets("Sheet2").Cells(i, 1) = commandline

I don't really know how to go from here.. This is only inputing the
file into one column and I need two or more columns.

Using the record macro like you said is ok but this would seem to work
so that I can define the starting and stopping point at where I need to
take the data. Such as taking lines 13 to 100 from the .dat file and
importing them to the worksheet.

Thanks,

Nuc


--
Nuc
------------------------------------------------------------------------
Nuc's Profile: http://www.excelforum.com/member.php...o&userid=28572
View this thread: http://www.excelforum.com/showthread...hreadid=482329

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Input data from file to Excel in Column Format

See Chip Pearson's site for sample code. Specify space as a delimiter:

http://www.cpearson.com/excel/imptext.htm import/export text files

--
Regards,
Tom Ogilvy


"Nuc" wrote in message
...

What about using an open statement such as:

'Open "file.dat" For Input As #1 'Open file for input to worksheet
'For i = 1 To ??
'Line Input #1, commandline
'Worksheets("Sheet2").Cells(i, 1) = commandline

I don't really know how to go from here.. This is only inputing the
file into one column and I need two or more columns.

Using the record macro like you said is ok but this would seem to work
so that I can define the starting and stopping point at where I need to
take the data. Such as taking lines 13 to 100 from the .dat file and
importing them to the worksheet.

Thanks,

Nuc


--
Nuc
------------------------------------------------------------------------
Nuc's Profile:

http://www.excelforum.com/member.php...o&userid=28572
View this thread: http://www.excelforum.com/showthread...hreadid=482329



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Input data from file to Excel in Column Format


Thanks for the info I will try and get this going.

Nuc


--
Nuc
------------------------------------------------------------------------
Nuc's Profile: http://www.excelforum.com/member.php...o&userid=28572
View this thread: http://www.excelforum.com/showthread...hreadid=482329



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
data input format Roy Gudgeon[_2_] Excel Discussion (Misc queries) 1 March 22nd 10 01:59 PM
Moving data in one excel column to another sheet based on user input [email protected] Excel Discussion (Misc queries) 1 May 10th 07 05:47 PM
Input data format from GIS Khoshravan Excel Discussion (Misc queries) 1 May 19th 06 10:05 AM
How do I easily format a column to convert input of 120307 to 12:. Gomer Excel Discussion (Misc queries) 3 February 10th 05 12:20 AM
Saving a column of data in another file format Hari Prasadh Excel Programming 12 February 1st 05 03:07 AM


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