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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
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,222,180
Messages
6,164,420
Members
451,894
Latest member
480BOY

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