Macro to save a tab with changing name

rwallage

New Member
Joined
May 28, 2006
Messages
34
Hi,

I have a file where data is entered, at the end a tab is saved as a separate file, all formulae and links are closed by a Copy Paste Special Values, and the separate file is closed. The filename should be a serial number, posted in a separate cell.

Currently, the macro looks like this:

Sheets("Docket").Select
Sheets("Docket").Copy
ActiveWorkbook.SaveAs Filename:="L:\FC\RENE\Goodies\docket laundry 01.xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWorkbook.Save
ActiveWorkbook.Close

The filename and location should come from a cell in another tab. How can I do this?
 

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.
Add
ActiveSheet.Name = "NewName"
 
Upvote 0
Maybe I'm not explaining myself clearly.
The file is to be used by people who are barely able to enter certain data in certain cells (the entire worksheet is protected). The data they enter goes into another tab, that is in a specific format for further processing. That tab is than extracted, using the macro above. It than needs to be saved with a new name. The name appears on the tab in cell J2.
 
Upvote 0
I'VE CRACKED IT!!!

Well, with a large dollop of help from other threads here...
This is what works for me:

ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Sheets("Docket").Range("J2")

Where "Docket" is the tab's name.
Now all I need to figure out, is how to add the location in the code...
 
Upvote 0
Solution
ActiveSheet.Name = ActiveSheet.Range("J2")
 
Upvote 0

Forum statistics

Threads
1,215,051
Messages
6,122,871
Members
449,097
Latest member
dbomb1414

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