Rename file based on cell

waterdog15

New Member
Joined
Dec 27, 2009
Messages
15
Is it possible to create a macro to rename and save a file based on a cells content? For example, if the name in cell C2 is "John Doe" and D3 has the word "April", I want to rename the current file to John Doe and the current worksheet to April. Can you do this?

Thanks in advance,
Paul
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Here are some examples

Code:
Sub SaveAndRename()
 Sheets(1).Name = Range("D3").Value
    ActiveWorkbook.SaveAs Filename:= _
        "C:\Documents and Settings\........\Testme\" & Range("C2").Value & ".xlsm", , FileFormat:= _
        xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
   
    
End Sub
 
Last edited:
Upvote 0
Thank-you. Is this the same for both 2003 and 2007? Also can you have it open the "Save As" dialog box and prepopulate the box with the name in the cell?

Thanks again,
Paul
 
Upvote 0

Forum statistics

Threads
1,214,561
Messages
6,120,245
Members
448,952
Latest member
kjurney

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top