98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Pivot Tables and SaveMe
Pivot Tables and SaveMe
Resolved · Low Priority · Version 2003
Deborah has attended:
Excel VBA Intro Intermediate course
Pivot Tables and SaveMe
We wrote a routine during the course to save the reports generated from the form as a separate file (SaveMe). Is it possible to include the associated pivot table as a separate worksheet in that saved file?
RE: Pivot Tables and SaveMe
Hi Deborah, thanks for your query. Saving out two worksheets into a separate file is no problem, but because of the nature of our code, there are some tweaks to be made.
First, you need to make strSalesPerson a publically declared variable so we can access it in the Saveme subroutine. Secondly, I have moved the call to SaveMe in the Main "dashboard" subroutine so it is here:
**********
If blnPivot = True Then
Call pivotstaffanalysis
End If
Call saveme
Exit Sub
*************
Essentially, I want to simplify things which means you have to tick the Pivot table check box for there to be an "Analysis" sheet to dump out. Once we've done that, the amended SaveMe routine looks like this:
**************
Dim mynewfilename As String
mynewfilename = "C:\" & strName & ".xls"
Sheets(Array(strSalesPerson, strName)).Select
Sheets(Array(strSalesPerson, strName)).Copy
ActiveWorkbook.SaveAs Filename:=mynewfilename
ActiveWorkbook.Close
**************
Ideally, the subroutine should be rewritten to cope with the user selecting a pivot table or otherwise, but you can see from the amended code how easy it is to dump out multiple selections of worksheets into standalone files.
Hope this helps,
Anthony
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
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Apply Autosum with keyboard shortcutIf you press Alt and = at the same time, it applies autosum. |