Text replacement with VBA Excel in several files
Hi pieros,
Try this replacing "C:\Temp\" with the path where you have the files::
Sub RenameFiles()
Set fs = Application.FileSearch
With fs
.LookIn = "C:\Temp\"
.SearchSubFolders = False
.Filename = "*KART*"
If .Execute() 0 Then
For i = 1 To .FoundFiles.Count
If .FoundFiles(i) Like "*503*" Then _
FileCopy .FoundFiles(i), Replace(.FoundFiles(i), "503",
"305")
Next i
End If
End With
End Sub
Regards,
KL
"pieros" wrote in message
oups.com...
Good morning,
I've got a folder with many subfolders in it filled with several text
files. Some of these text files have a filename with "KART" in it.
In these files (with "KART" in their filenames) I have to replace the
text "503" in "305".
Can anyone please help met with VBA code?
Many Thanks.
|