ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to Search and Replace (https://www.excelbanter.com/excel-programming/311198-macro-search-replace.html)

Excel_Rookie[_3_]

Macro to Search and Replace
 

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

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

Thanks

--
Excel_Rooki
-----------------------------------------------------------------------
Excel_Rookie's Profile: http://www.excelforum.com/member.php...fo&userid=1467
View this thread: http://www.excelforum.com/showthread.php?threadid=26287


Bernie Deitrick

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





All times are GMT +1. The time now is 12:45 PM.

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