Solved

VBA Excel 2000 - Pivot "Paste Special as Values"

Posted on 2011-02-15
6
654 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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