Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
if then elseif on text file imported into excel
Well here goes. I have already built a macro (with the help of reading
from the group...thx)that will allow me to open a specific text file in excel. Now after opening the file I need to sort/parse all of the information into specific columns and place the data that occurs after the keyword in that column. My thoughs were to create a loop that would key off of those words and capture all data until the next keyword occurred. I would normally use awk on something like this but those tools are not available to me. So... I guess I am asking is this possible with excel macros or should I use other tools. I am I heading in the wrong direction???? Here is an abrivated sample of the file: system_name sys_1 sys_2 sys_3 user_table administrator user_1 user_2 user_3 group administrator dba sap What I need to do is have the module key off of the terms system_name, user_table, group and capture the data after that keyword and place it into the column under each keyword. Example: system_name user_table group sys_1 administrator administrator sys_2 user_1 dba sys_3 user_2 sap |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
iTunes Library text file imported into Excel | Excel Discussion (Misc queries) | |||
formatting a text file imported into excel | Excel Worksheet Functions | |||
how do I remove page headings from an imported text file | Excel Discussion (Misc queries) | |||
imported doc from pdf file, want to seperate text & date in cells | Excel Discussion (Misc queries) | |||
can I display the file name of the imported text file in another c | Excel Discussion (Misc queries) |