ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using .filesearch for text within a file (https://www.excelbanter.com/excel-programming/358313-using-filesearch-text-within-file.html)

Michael Wise[_32_]

Using .filesearch for text within a file
 

Is there a way to search for mutiples of specific text within a .txt
file. For instance I'm needing to find a constant value "Y31" and then
a variable value at the same time like "36601". These 2 values are not
in the same line. I do want this file opened once found. I'm currently
using .filesearch and have tried various wildcards, .textorproperty
techniques but have not found a solution. Thanks for any suggestions.

Current Code (does not completely do what I want to do):

Sub FindPOFile()
Dim I As Integer
Worksheets("Data").Select
Cells.Select
Selection.ClearContents
5 si = Worksheets("Setup").Range("C4")
With Application.FileSearch
..NewSearch
..LookIn = "\\txnt34\g-tx-virtual"
..TextOrProperty = si
..MatchTextExactly = True
..Filename = "*.txt"
..Execute


For I = 1 To .FoundFiles.Count

If I = 2 Then MsgBox ("More than one file was found matching your
criteria")

Workbooks.Open .FoundFiles(I)

Next I

End With
If I = 1 Then GoTo 5

Cells.Select
Selection.Copy
Windows("Outstanding PO Tool.xls").Activate
Sheets("Data").Select
ActiveSheet.Paste


--
Michael Wise
------------------------------------------------------------------------
Michael Wise's Profile: http://www.excelforum.com/member.php...fo&userid=6998
View this thread: http://www.excelforum.com/showthread...hreadid=530893


Michael Wise[_33_]

Using .filesearch for text within a file
 

Anyone have any suggestions? Am I considering the wrong method?


--
Michael Wise
------------------------------------------------------------------------
Michael Wise's Profile: http://www.excelforum.com/member.php...fo&userid=6998
View this thread: http://www.excelforum.com/showthread...hreadid=530893



All times are GMT +1. The time now is 05:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com