![]() |
Copying only required string from txt file to excel sheet
Hi ,
i am preparing one report in excel sheet. For which i got txt file as input. Which contains some strings. but, my interest is in particular format of string or line. For example File name - tst.txt L1 - return (&SUP_GPTA_TC_GROUP[channel].TCCTRL_reg); L2 - D:\p\S83\C01\iiii\zzz\00\XXX\yyy.h 2423 Info 826: Suspicious pointer-to-pointer conversion (area too small) <D.23: Use pointers as declared (EXPR) |
Copying only required string from txt file to excel sheet
Sub Gettext()
Const ForReading = 1, ForWriting = 2, ForAppending = 3 Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 Set fsread = CreateObject("Scripting.FileSystemObject") FName = Application.GetOpenFilename("All files (*.*),*.*") Set fread = fsread.GetFile(FName) Set tsread = fread.OpenAsTextStream(ForReading, TristateUseDefault) RowCount = 1 Do While tsread.AtEndOfStream = False InputLine = tsread.ReadLine If InStr(InputLine, "D:\p\S83\") 0 Then Range("A" & RowCount) = InputLine RowCount = RowCount + 1 End If Loop tsread.Close End Sub "sangram" wrote: Hi , i am preparing one report in excel sheet. For which i got txt file as input. Which contains some strings. but, my interest is in particular format of string or line. For example File name - tst.txt L1 - return (&SUP_GPTA_TC_GROUP[channel].TCCTRL_reg); L2 - D:\p\S83\C01\iiii\zzz\00\XXX\yyy.h 2423 Info 826: Suspicious pointer-to-pointer conversion (area too small) <D.23: Use pointers as declared (EXPR) . . . I want only line L2 ( or lines containing pattern D:\p\S83\ ) to be copied from tst.txt file to excelsheet. Can you suggest me way to do this using excelsheet programming. Thanks in advance sangram |
All times are GMT +1. The time now is 07:04 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com