How do you rename your Excel worksheet the same as the filename using a macro?
I have approximately A HUNDRED workbooks in one directory.Each workbook has a single worksheet.I’d like tor rename the actual worksheet inside each workbook that they are just as the filename (without the actual extension).Can you really do a batch in case not what is a macro
Assume you are aware of where to put this macro, back up your ONE HUNDRED workbooks 1st, put the actual excel document that go this code considering the 100 other workbooks, subsequently run that code.
Sub-contract fname2sname()
‘this value change the very first sheet name of every xls file
‘in exactly the same folder of your file to help its document name a lesser amount of extension
Fixed fs = CreateObject( “Scripting.FileSystemObject”)
Fixed fl = fs.GetFolder( ThisWorkbook.Method & “\”)
Per f Throughout fl.Files
Whenever Right(f.Brand, 4) = “.xls” And f.Brand ThisWorkbook.Brand Then
Fixed ow = Workbooks.Open(f.Name)
Having ow
.Sheets(1).Brand = Left(f.Brand, Len(f.Name) — 4)
.Save
.Preserved = True
.Close
End With
Fixed ow = Nothing
End If
Next
End Sub
Please contact for more info.
Leave a Reply
You must be logged in to post a comment.