"Save As" Macro problem

levanduski00

New Member
Joined
Sep 18, 2002
Messages
2
First let me begin by mentioning that I'm a complete beginner, but I very much want to learn to program macros to make my life easier at work.

My current project requires that I take four specific worksheets out of a workbook of 20 sheets and create a new workbook saved as "MMM_DD" format. For example "Oct_01". The date would be obtained using a cell refence from one of the copied worksheets.

I used the macro recorder to do most of the programming, however I'm very unclear how I can use the information from a specific cell to specify the filename. The refernce cell is a date, and I want to save the file by date.

Please let me know if you have any suggestions or if you need more information regarding my situation.

Thanks,
Roger
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi

Always best to post up what you have ion code even if dont work or has error, so we have some thing to work on.

Then we can add to what you have makes learning easir
 
Upvote 0
Hi.
Welcome...

The macro recorder is great. I use it all of the time but it is very limited and the code, even if it works for you, can usually be optimized. There are very many methods which cannot be duplicated with the recorder.

As for your current problem. Always post you code for a better example. This assumes that your date is in sheet1, cell A1 and saves the workbook accordingly. Change the path and sheet names accordingly.

<pre>
Sub CopyToNewBook()
Sheets(Array("Sheet1", "Sheet2", "Sheet3", "Sheet4")).Copy
ActiveWorkbook.SaveAs "C:Documents and SettingsAdministratorDesktop" & _
Format(Sheet1.Range("A1").Value, "MMM_DD") & ".xls"
ActiveWorkbook.Close
End Sub

</pre>
Tom
 
Upvote 0
Hi TsTom:

I like the code -- beautiful, compact, and does everything the OP asked!

Regards!

Yogi
 
Upvote 0

Forum statistics

Threads
1,214,912
Messages
6,122,200
Members
449,072
Latest member
DW Draft

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