Use filtered list as FileName with FileSearch?

E

Ed

I have a macro which uses FileSearch to do a text search of Word documents
in a specified folder. These documents are named by their report number,
which begins with "L5-", has a varying letter designator, and then a report
number. Currently, the user can input the letter designator into a cell,
which yields "strName" to constrain the search to a general report series.
What I would like to be able to do is filter my worksheet for more specific
parameters, then use the results as the FileName property.

For instance, if I have 1400 "D" series reports, but the data I want may be
contained only in 100 of them and I can filter down to that group of 100,
how can I loop through my filtered column to use each cell value as the
FileName?

Ed

With Application.FileSearch
.NewSearch
.LookIn = strLocation
.SearchSubFolders = False
.TextOrProperty = strSearchFor
.Filename = "L5-" & strName & "*.doc"
.Execute
 
T

Tom Ogilvy

Dim rng as Range
Dim rng1 as Range
set rng = Intersect(Activesheet.columns(3),Activesheet.Autofilter.Range)
set rng = rng.offset(1,0).Resize(rng.rows.count-1)
On Error Resume Next
set rng1 = rng.SpecialCells(xlVisible)
On Error goto 0
if not rng1 is nothing then
for each cell in rng1
msgbox cell.Value

Next
End If
 
E

Ed

Thank you so much, Tom!

Ed

Tom Ogilvy said:
Dim rng as Range
Dim rng1 as Range
set rng = Intersect(Activesheet.columns(3),Activesheet.Autofilter.Range)
set rng = rng.offset(1,0).Resize(rng.rows.count-1)
On Error Resume Next
set rng1 = rng.SpecialCells(xlVisible)
On Error goto 0
if not rng1 is nothing then
for each cell in rng1
msgbox cell.Value

Next
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top