Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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

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
iTunes Library text file imported into Excel Craig J Excel Discussion (Misc queries) 4 September 13th 09 12:25 AM
formatting a text file imported into excel GinaH Excel Worksheet Functions 1 August 6th 09 08:30 PM
how do I remove page headings from an imported text file amaries Excel Discussion (Misc queries) 1 December 4th 08 09:10 PM
imported doc from pdf file, want to seperate text & date in cells Christian Excel Discussion (Misc queries) 2 February 2nd 06 08:13 PM
can I display the file name of the imported text file in another c John-G Excel Discussion (Misc queries) 0 May 13th 05 03:38 PM


All times are GMT +1. The time now is 06:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"