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


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
copying a date into a text string Looking for help Excel Worksheet Functions 3 September 6th 08 02:57 PM
How to disallow a sheet or file from copying by other users JIGNESH MISTRY Excel Discussion (Misc queries) 1 August 27th 08 01:58 PM
Excel converts string in CSV file as number DavidC Excel Discussion (Misc queries) 5 July 25th 08 02:37 PM
How can I transfer a required data from sheet 1 to sheet 2 automat Malik Nadeem Excel Discussion (Misc queries) 6 October 24th 07 11:48 AM
variable text value within string formula required to sum column Tester Excel Worksheet Functions 2 December 8th 06 01:07 PM


All times are GMT +1. The time now is 02:39 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"