Home |
Search |
Today's Posts |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It's fantastic how it works. If i didnt got this i had to do many
steps to get it right and that would cost alot of time wich can be spent more wisely. Thanks Joel! Again like to send you some flowers or something :) Joel wrote: I like to help! It always easier to get the interface working correctly then to try to fix the problems later on. Moving cells around in excel can become complicated and is slower then modifying the text file which is the source of your problem. " wrote: JOEL Thanks so much!!! This is fantastic. It's 100% what i was looking for! Can't i send you a present :)? Thanks!!! J.Lemmens Joel wrote: I didn't notice the comment at the bottom your posting that you added the "____" to the file. I thought it was part of the data. This should work Sub Gettext() Const ForReading = 1, ForWriting = 2, ForAppending = 3 Const MyPath = "C:\temp\" Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 Set fsread = CreateObject("Scripting.FileSystemObject") Set fswrite = CreateObject("Scripting.FileSystemObject") ReadFileName = "longtext.txt" WriteFileName = "longtext.csv" 'open files ReadPathName = MyPath + ReadFileName Set fread = fsread.GetFile(ReadPathName) Set tsread = fread.OpenAsTextStream(ForReading, TristateUseDefault) WritePathName = MyPath + WriteFileName fswrite.CreateTextFile WritePathName Set fwrite = fswrite.GetFile(WritePathName) Set tswrite = fwrite.OpenAsTextStream(ForWriting, TristateUseDefault) Do While tsread.atendofstream = False InputLine = tsread.ReadLine If (InStr(InputLine, "TEXT") 0) Then If Len(OutPutLine) 0 Then tswrite.WriteLine OutPutLine OutPutLine = "" End If Else If Len(OutPutLine) 0 Then OutPutLine = OutPutLine + "," + InputLine Else OutPutLine = InputLine End If End If Loop tswrite.Close tsread.Close Exit Sub End Sub " wrote: Thanks so much for the helping hand; This is what the txt file looks like: _______________________________SHEET 7K294 0,2949.41 276.52,3104.61 TEXT _______________________________7K294 1.8 NORMAL 271.02,32.11 TEXT _______________________________TRANSPORTSYSTEM - A 1.5 NORMAL 193.62,32.91 TEXT _______________________________CENTER SYSTEM 1.5 NORMAL 193.42,28.61 TEXT _______________________________SFC STEP 4 - WAIT 1.5 NORMAL 193.42,24 TEXT 1256345 1.2 NORMAL 223.55,20 TEXT A 1.2 NORMAL 195.78,15 TEXT 12-12-06 1.2 NORMAL 193.22,12.1 TEXT SHEET 7K2946 etc ---------------------------------------- To understand the "important" lines to collect I have put _______________________________ in from of the data to make it more understanable in this post. As you can see i need line 4, 9,14,19 to copy to columns B,C,D,E in excel (see prev. post). Thanks so much!!! Best Regards |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy a file with only values no formulas | New Users to Excel | |||
Copy and paste special - values into new excel file | Excel Discussion (Misc queries) | |||
Urgent Help needed on! Copy and Paste a Formula as Values using a Loop statement | Excel Programming | |||
Copy values from file A, Find/Replace these values in File B | Excel Programming |