Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selective read data from ascii file
Dave,
Thanks a lot... -- steve "Dave Peterson" wrote in message ... One way: Option Explicit Sub testme03() Dim myFileName As String Dim myFileNum As Long Dim skipThisPart As Boolean Dim myLine As String Dim wks As Worksheet Dim oRow As Long Set wks = Worksheets.Add myFileName = "C:\my documents\excel\test\test.txt" myFileNum = FreeFile() Close #myFileNum Open myFileName For Input As #myFileNum oRow = 0 skipThisPart = False Do While Not EOF(myFileNum) Line Input #myFileNum, myLine If LCase(myLine) Like "[#] section 2*" Then skipThisPart = True ElseIf LCase(myLine) Like "[#] section 3*" Then skipThisPart = False End If If skipThisPart Then 'do nothing Else oRow = oRow + 1 wks.Cells(oRow, 1).Value = myLine End If Loop Close #myFileNum End Sub You may want to parse the data into the correct cells or maybe do Data|Text to columns after you import the raw data. Steve Kim wrote: All, I have an Excel file need to read data from another ascii file, then perform certain calculation. The ascii file formats like following: # section 1 ....... # section 2 .... # section 3 ..... Since the section 2 of the ascii is huge, I want to ignore all the data from section 2. How can I write macro to read that ascii file but ignore all data between # section 2 and # section 3. Thanks a lot. -- steve -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Merge data from an ascii file into a Word doc | Excel Discussion (Misc queries) | |||
How do I convert an Excel file to an ASCII file? | Excel Discussion (Misc queries) | |||
How do I convert an Excel file to an ASCII file? | New Users to Excel | |||
using data from ascii file? | Excel Discussion (Misc queries) | |||
How do I convert excel file into ASCII text file with alignment? | Excel Discussion (Misc queries) |