E
electrica7926
Does anyone have a macro that will rename excel files with text from
cell within the file
cell within the file
Tom Ogilvy said:Dim sPath as String, sNameOld as StringDim sName as StirngDim i as LongWith
Application.FileSearch .NewSearch .LookIn = "C:\My Documents"
.SearchSubFolders = True .FileName = ".xls" .FileType =
msoFileTypeExcelWorkbooks If .Execute() > 0 Then For i = 1 To
.FoundFiles.Count set wkbk = workbooks.open( .FoundFiles(i))
sPath = wkbk.Path if right(spath,1) <> "\" then spath = spath &
"\" sNameOld = wkbk.FullName sName =
wkbk.Worksheets(1).Range("A1").Value wkbk.close SaveChanges:=False
name sNameOld as sPath & sName Next i Else MsgBox "There
were no files found." End IfEnd With-- Regards,Tom Ogilvy"electrica7926
msoFileTypeAllFiles" and it worked. I don't know why it didn't work before,JoyB said:Nevermind! I added the ".MatchTextExactly = True" and ".FileType =
Tom said:*It used to be that rename meant
"C:\Source Directory" = "C:\Destination Directory\"
and the file ceased to exist under the old name.
Maybe not anymore, eh?*