Solved

VBA Excel 2000 - Pivot "Paste Special as Values"

Posted on 2011-02-15
6
658 Views
Last Modified: 2016-08-25
Dear Experts,

In the daily work I am creating a lot of pivot tables, but typically needed only their numbers and not the pivot table itself with all of the wizard, formating etc functions.

So for this used to apply that selecting the pivot "arounding area", right click copy, after paste special as values. Can not do that copy on the pivot area itself and right click, because in Excel 2000 there is no copy option in the list.

Could you advise how to do it differently? Is there some command in VBA which would copy the pivot itself and paste special as values?

thanks,
0
Comment
Question by:csehz
  • 3
  • 2
6 Comments
 
LVL 26

Expert Comment

by:redmondb
ID: 34897110
csehz,


Yes, this could be done in a macro, but that's not necessary.

"Copy" is missing from the Context menu (it could, of course, be added), so simply use it from the menu bar - "Edit" then "Copy", followed by the "Paste Special".

Regards,
Brian.
0
 
LVL 1

Author Comment

by:csehz
ID: 34904573
Brian thanks, but I would need this in VBA.

For example in the attached code there is a pivot with name "PivotTable8".

How this could be copied and paste to new sheet with Paste Special as Values?


ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
        "Sheet1!R1C1:R16C3").CreatePivotTable TableDestination:="", TableName:= _
        "PivotTable8"
    ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
    ActiveSheet.Cells(3, 1).Select
    ActiveSheet.PivotTables("PivotTable8").SmallGrid = False
    ActiveSheet.PivotTables("PivotTable8").AddFields RowFields:="Item", _
        ColumnFields:="Area"
    With ActiveSheet.PivotTables("PivotTable8").PivotFields("Qty")
        .Orientation = xlDataField
        .Caption = "Sum of Qty"
        .Function = xlSum
        .NumberFormat = "# ##0"
    End With

Open in new window

0
 
LVL 26

Accepted Solution

by:
redmondb earned 500 total points
ID: 34905162
csehz,

No problem...

Sub UnPivot()

ActiveSheet.PivotTables("pivottable8").TableRange2.Copy
ActiveSheet.PivotTables("pivottable8").TableRange2.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

End Sub

Open in new window


Regards,
Brian.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Author Closing Comment

by:csehz
ID: 34905190
Brian thanks very much.. Exactly this I searched, thanks just again
0
 
LVL 26

Expert Comment

by:redmondb
ID: 34905256
csehz,

Many thanks!

All the best,
Brian.
0
 

Expert Comment

by:Nil Rudra
ID: 41770102
Thanks I was need same code.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question