Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

saving macro generated reports

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Saving macro generated reports

Saving macro generated reports

ResolvedVersion 2003

Simon has attended:
Excel VBA Intro Intermediate course

Saving macro generated reports

Can you show me the code for saving the report in a new file / folder rather than in the data worksheet. Thanks

RE: Saving macro generated reports

Hi Simon, thanks for the query. Here's the code you need. Make sure the mynewfilename variable is set your desktop (it's set to mine in the example below). The code copies strName to a new file, then saves that file to the desktop.

***

Dim mynewfilename As String

mynewfilename = "C:\Documents and Settings\User10\Desktop\" & strName & ".xls"

Sheets(strName).Select
Sheets(strName).Copy
ActiveWorkbook.SaveAs Filename:=mynewfilename

ActiveWorkbook.Close


***

Hope this is useful!

Anthony

Sun 31 Jan 2010: Automatically marked as resolved.

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

##### displaying in Excel

When you get a series of hash symbols (####) appearing in some of your cells in a spreadsheet, this can make you think that you've make some kind of mistake.

This is a common misconception - what this actually means is that the cell is not wide enough to fully display the content of the cell.

All you need to do to see what is actually in the cell is to widen the column that the cell is in.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.