LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Search multiple strings in one text file

I wish to search for 2 separate strings in one file. I prefer to not follow
this sequence: (1) Open txt file (2) search for first string (3) output
result (4) close txt file (5) repeat 1-4 for second string. I would like to
perform the query without having to close and reopen the txt file. My
current program resembles what it listed below. Obviously my syntax for
"LineofText2" is incorrect, so please offer your suggestions. Is possible to
do something along the lines of "Open fName For Input As #1 and #2"? thanks
in advance.

Open fName For Input As #1
sStr = ""
sStr2 = ""
Do While Not EOF(1)
Line Input #1, LineofText
If (InStr(1, LineofText, "Reboot", vbTextCompare)) Then
sStr = Left(LineofText, 12)
End If
If (InStr(1, LineofText2, "Yes", vbTextCompare)) Then
sStr2 = Mid(LineofText2, 12, 3)
End If
Loop
Cells(iVar, "A").Value = sStr
Cells(iVar, "B").Value = sStr2
Close #1
 
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
search for multiple strings Lea from CA[_2_] Excel Discussion (Misc queries) 4 October 16th 09 10:20 PM
How do I filter or search mulitple for text strings? MikeD Excel Discussion (Misc queries) 2 October 29th 08 01:07 PM
Search for multiple strings in a list (w/in 1 cell) w/ Advanced fi Maher Excel Discussion (Misc queries) 5 July 7th 08 06:02 PM
Search multiple strings in each cell Dave Peterson Excel Programming 7 December 18th 06 06:05 PM
Search multiple strings Difficult to figure out Jeff Excel Programming 2 November 23rd 06 04:18 AM


All times are GMT +1. The time now is 08:07 AM.

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

About Us

"It's about Microsoft Excel"