LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Import selected lines from an Ascii file


does this give you the start you need?
it writes the lines of the blocks to columns 1 and 2 of the activesheet

once this has run you can parse those ranges with texttocolumns method



Sub ReadFromAscii()
Dim sLine$, sBlock$
Dim a&, c&

Open "c:\myascii.txt" For Input As #1

Do While Not EOF(1)
Line Input #1, sLine

If Left(sLine, 1) = "~" Then
If Left(sLine, 2) = "~C" Then
sBlock = "C"
ElseIf Left(sLine, 2) = "~A" Then
sBlock = "A"
Else
sBlock = ""
End If
Else
Select Case sBlock
Case "C"
c = c + 1
ActiveSheet.Cells(c, 1) = sLine
Case "A"
a = a + 1
ActiveSheet.Cells(a, 2) = sLine
End Select
End If
Loop
Close #1

End Sub



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


?B?ZHJib2JzbGVk?= wrote:


I have an ascii file that has data organized in blocks.
Each block's header line has a "~" in column 1.
eg.
~Well Information Block

How can I import the data in the "Curve information block" and the
"~ASCII DEPTH" or sometimes called "~A DEPTH" blocks only?

I 've included some sample data.


 
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 csv file - blank lines inserted Dave Peterson Excel Discussion (Misc queries) 0 February 21st 07 01:56 AM
How do I convert excel file into ASCII text file with alignment? Rosaiah Excel Discussion (Misc queries) 2 June 27th 05 12:17 PM
Ascii file import round 3 Mad Scientist Excel Programming 1 January 8th 04 10:40 PM
ascii file import round 2 Mad Scientist Excel Programming 1 January 8th 04 08:47 PM
Import ascii file Mad Scientist Excel Programming 2 January 8th 04 01:38 AM


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