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

anthony discussed

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Anthony as discussed??

Anthony as discussed??

ResolvedVersion 2003

Rudolph has attended:
Excel VBA Intro Intermediate course

Anthony as discussed??

How can the results of a query be created in a new file into a completely different folder, after running the macro for reports?

RE: Anthony as discussed??

Hi Rudolph, 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:

Quickly copy a formula across sheets

Suppose you have a formula in cell Sheet1!B2, say =A1*5%, that you wish to copy to cell B2 on Sheet2, Sheet3 and Sheet4. Instead of using copy and paste, try this: (1) Select Sheet1!B2. (2) Group Sheet1 with the worksheets Sheet2, Sheet3 and Sheet4 by holding down Ctrl and clicking on the tabs of the sheets to group them. (3) Press the F2 key, then immediately press Enter to copy the formula in Sheet1!B2 across the grouped sheets.

Remember to ungroup the sheets afterwards! Right-click on any tab and choose Ungroup Sheets to do that.

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.