View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Steved[_3_] Steved[_3_] is offline
external usenet poster
 
Posts: 76
Default Formula Find Issue

Hello from Steved

Below Opens all files and closes in the directory which
is working correctly, but I would like it stay open when
2201 is found as at this time it opens and closes all
files. Help please I am Close.

Set FoundCell = WB.Worksheets(1).Cells.Find(what:=2201)

Thankyou.

Sub Test2()
Dim FName As String
Dim FoundCell As Range
Dim WB As Workbook
ChDrive C: '<<< CHANGE
ChDir "C:\Wtt" '<<< CHANGE
FName = Dir("*.xls")
Do Until FName = ""
Set WB = Workbooks.Open(FName)
Set FoundCell = WB.Worksheets(1).Cells.Find
(what:=2201)
If Not FoundCell Is Nothing Then
' do something with FoundCell
Else
' not found
End If
WB.Close SaveChanges:=True ' or False
FName = Dir()
Loop
End Sub