Saving New File Name in a macro

Gman1950

New Member
Joined
Aug 27, 2002
Messages
15
I have a excle file that I call a templete file with a macro attached. The macro when run copies & pastes data from another excel file that was downloaded from a dbf file. After the macro copies & pastes the data I need to save the templete file with a new name using "save as". What I need to do is that when I use the "save as" feature that saves the templete file as a NEW excel file with a different name. It will put the NEW excel file name in the macro, that way I'll be able to use the macro with the NEW file. I will need to run the macro to copy & paste additional downloaded data in the week to the NEW file. Can anyone give me a hand. (Hope everyone understood what I am trying to do).
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Gman1950
There have been a number of posts to this message board about saving workbooks - some using "getfilename" to allow the user to specify a filename, others pulling the NEW filename from a cell in the workbook.
Search the board for "Save As", "Getfilename", etc and you'll have more VBA code than you want.

HTH
BigC
 
Upvote 0
just got done with a project that incorp just what you are looking for.

I used a cell to pass a variable to a save as statement.

That is the cell contained the name of what I wanted the file to be named.

I also needed to save to multiple locations so I did the same thing for the File Path

here is a bit of the code:

Dim loc As String
dim Fname as string

Fname = Sheets("Project Worksheet").Range("d7").Value ' whatever is in d7 will be the file name

loc = Sheets("Project Worksheet").Range("j22").Value ' file location for file to be saved to.

ActiveWorkbook.SaveAs Filename:=" " & Fname & " " & loc & " "

hope this helps
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,999
Members
448,541
Latest member
iparraguirre89

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