ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multiple criteria Filesearch function (https://www.excelbanter.com/excel-programming/310896-multiple-criteria-filesearch-function.html)

Michael Wise[_15_]

Multiple criteria Filesearch function
 

i dont see DOTS within the With/End With construct..


Keepitcool, there are dots there. The functions works as long as th
criteria is within the quotes or as a variable. The problem comes whe
trying to set it to look for both the variable 'usid' an
"EQSERVICEMAC

--
Michael Wis
-----------------------------------------------------------------------
Michael Wise's Profile: http://www.excelforum.com/member.php...nfo&userid=699
View this thread: http://www.excelforum.com/showthread.php?threadid=26236


keepITcool

Multiple criteria Filesearch function
 
would be easier if you stay within the thread, by replying :)

Following works for my and finds the txt files containting:
AnyTextEQSERVICEMAC

Sub ff()
Dim usid As String
Dim i As Integer

usid = "AnyText"

With Application.FileSearch
.NewSearch
.LookIn = "\\txnt34\g-tx-virtual"
.Filename = "*.txt"
.TextOrProperty = usid & "EQSERVICEMAC"
.MatchTextExactly = False
.Execute

If .FoundFiles.Count = 0 Then GoTo wait

For i = 1 To .FoundFiles.Count
Workbooks.Open .FoundFiles(i)
Next i


End With
Exit Sub

wait:
MsgBox "No files found"

End Sub




keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


Michael Wise wrote:


i dont see DOTS within the With/End With construct..


Keepitcool, there are dots there. The functions works as long as the
criteria is within the quotes or as a variable. The problem comes when
trying to set it to look for both the variable 'usid' and
"EQSERVICEMAC"





All times are GMT +1. The time now is 04:16 PM.

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