View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Macro to Search and Replace

Hey Rookie,

If the files are all in the same folder, and are only one sheet long, then
something like this will do it:

Sub RunMacroOnAllFilesInFolder()
With Application.FileSearch
.NewSearch
'Change the folder name
.LookIn = "C:\Excel"
.FileType = msoFileTypeExcelWorkbooks
If .Execute 0 Then
For i = 1 To .FoundFiles.Count
Workbooks.Open .FoundFiles(i)
'Put your recurring macro code here
Cells.Replace What:="FindThis", _
Replacement:="Replacement", _
LookAt:=xlPart
ActiveWorkbook.Close True
Next i
End If
End With
End Sub

HTH,
Bernie
MS Excel MVP

"Excel_Rookie" wrote in message
...

I'm wondering if its possible to have a macro that will find cells with
specified text and replace it with other specified text.

I have a lot of files that have these same cells that need to be
modified and looking for a way to save time.

Thanks.


--
Excel_Rookie
------------------------------------------------------------------------
Excel_Rookie's Profile:

http://www.excelforum.com/member.php...o&userid=14670
View this thread: http://www.excelforum.com/showthread...hreadid=262879