Solved

VBA Excel 2000 - Pivot "Paste Special as Values"

Posted on 2011-02-15
6
648 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
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.
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

743 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now