Renaming Workbooks based on Cell Value with VBA

Jambi46n2

Board Regular
Joined
May 24, 2016
Messages
243
Office Version
365, 2019
Platform
Windows
The code below works with renaming workbooks, however it also moves them as well.

Is there a way to modify the code to make a copy of the workbook instead of moving it?

Thanks much in advance!

Code:
Sub RenameTesting()


Dim OldName1, NewName1

'Work books based on cell values below
OldName1 = [F10]: NewName1 = [C10]

'Renames workbooks and moves workbooks
Name OldName1 As NewName1

End Sub
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
35,978
Office Version
365
Platform
Windows
How about
Code:
   Dim Fso As Object
   Set Fso = CreateObject("scripting.filesystemobject")
   Fso.CopyFile OldName1, NewName1
 
Last edited:

Jambi46n2

Board Regular
Joined
May 24, 2016
Messages
243
Office Version
365, 2019
Platform
Windows
Thanks for the prompt response Fluff, you sir are a gentleman and a scholar!
 
Last edited:

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
35,978
Office Version
365
Platform
Windows
What error number & message did you get?
 

Jambi46n2

Board Regular
Joined
May 24, 2016
Messages
243
Office Version
365, 2019
Platform
Windows
What error number & message did you get?
The error message was human error on my part.

Can't thank you enough again.

I sincerely appreciate it.
 
Last edited:

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
35,978
Office Version
365
Platform
Windows
You're welcome & thanks for the feedback
 

Watch MrExcel Video

Forum statistics

Threads
1,090,200
Messages
5,413,001
Members
403,462
Latest member
TritonCoding

This Week's Hot Topics

Top