View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
TheDuck[_2_] TheDuck[_2_] is offline
external usenet poster
 
Posts: 1
Default if then elseif on text file imported into excel

Mike,

Try this ...

It relies on the data being delimited with a comma rather than a space
Nor does it like the data being split over multiple lines but it shoul
provide enough of a pointer to get you the rest of the way.

Hope it helps,

TheDuck
+++++++++++++++++++++++++++++++++++++


Sub Parse_and_Sort()
Dim fileName As String
Dim curWord As String
Dim curCol As Integer, curRow As Integer

fileName = "data.txt"
Open fileName For Input As #1

Do Until EOF(1)
Input #1, curWord

Select Case curWord
Case "system_name":
curCol = 1
curRow = 1
Case "user_table":
curCol = 2
curRow = 1
Case "group":
curCol = 3
curRow = 1
Case Else:
curRow = curRow + 1
End Select

ActiveSheet.Cells(curRow, curCol) = curWord
Loop

Close #1
End Su

--
Message posted from http://www.ExcelForum.com