Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default How to export pivot table to a plain table?

Hi all,

I need some help. I have a pivot table, and I have to create it's plain copy
in a new workbook, but preserving the layout (i.e., it should be a plain
table looking exactly as the pivot table).

I tried to use the following code:

Sub Export_PivotTable()
Sheets("Table").PivotTables(1).PivotSelect "", xlDataAndLabel, True
Selection.Copy

Set New_Book = Workbooks.Add
New_Book.Sheets(1).Range("a1").Select
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
End Sub

However, it fails on line Selection.PasteSpecial Paste:=xlPasteValues
(gives Error 1004: PasteSpecial method..failed)

What's wrong with my code?

Or maybe anybody knows a more elegant way to export a pivot table to a plain
table without loosing the layout and formatting?

Thanks in advance -

RADO


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default How to export pivot table to a plain table?

RADO,

Your copied table is lost when you add your workbook. You need to add
the workbook prior to the copying to allow the pasting.

See the code example below.

HTH,
Bernie
MS Excel MVP

Sub Export_PivotTable()

Dim New_Book As Workbook
Dim Old_Book As Workbook

Set Old_Book = ActiveWorkbook
Set New_Book = Workbooks.Add

Old_Book.Activate
Sheets("Table").Activate
ActiveSheet.PivotTables(1).PivotSelect "", xlDataAndLabel
Selection.Copy

New_Book.Activate
Sheets(1).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
End Sub


"RADO" wrote in message
...
Hi all,

I need some help. I have a pivot table, and I have to create it's

plain copy
in a new workbook, but preserving the layout (i.e., it should be a

plain
table looking exactly as the pivot table).

I tried to use the following code:

Sub Export_PivotTable()
Sheets("Table").PivotTables(1).PivotSelect "", xlDataAndLabel,

True
Selection.Copy

Set New_Book = Workbooks.Add
New_Book.Sheets(1).Range("a1").Select
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
End Sub

However, it fails on line Selection.PasteSpecial

Paste:=xlPasteValues
(gives Error 1004: PasteSpecial method..failed)

What's wrong with my code?

Or maybe anybody knows a more elegant way to export a pivot table to

a plain
table without loosing the layout and formatting?

Thanks in advance -

RADO




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to export pivot table to a plain table?

It is possible that adding a workbook is causing your data to be lost and
therefore you can't paste. Try doing the copy after the you add the
workbook.

Sub Export_PivotTable()
Dim rng as Range
set rng = Sheets("Table").PivotTables(1).TableRange2

Set New_Book = Workbooks.Add
New_Book.Sheets(1).Range("a1").Select
rng.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
End Sub

--
Regards,
Tom Ogilvy


"RADO" wrote in message
...
Hi all,

I need some help. I have a pivot table, and I have to create it's plain

copy
in a new workbook, but preserving the layout (i.e., it should be a plain
table looking exactly as the pivot table).

I tried to use the following code:

Sub Export_PivotTable()
Sheets("Table").PivotTables(1).PivotSelect "", xlDataAndLabel, True
Selection.Copy

Set New_Book = Workbooks.Add
New_Book.Sheets(1).Range("a1").Select
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
End Sub

However, it fails on line Selection.PasteSpecial Paste:=xlPasteValues
(gives Error 1004: PasteSpecial method..failed)

What's wrong with my code?

Or maybe anybody knows a more elegant way to export a pivot table to a

plain
table without loosing the layout and formatting?

Thanks in advance -

RADO




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default How to export pivot table to a plain table?

Tom - thanks, works very nicely! As always, you are very helpful - I much
appreciate your time and advice.

Best,
RADO


"Tom Ogilvy" wrote in message
...
It is possible that adding a workbook is causing your data to be lost and
therefore you can't paste. Try doing the copy after the you add the
workbook.

Sub Export_PivotTable()
Dim rng as Range
set rng = Sheets("Table").PivotTables(1).TableRange2

Set New_Book = Workbooks.Add
New_Book.Sheets(1).Range("a1").Select
rng.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
End Sub

--
Regards,
Tom Ogilvy


"RADO" wrote in message
...
Hi all,

I need some help. I have a pivot table, and I have to create it's plain

copy
in a new workbook, but preserving the layout (i.e., it should be a plain
table looking exactly as the pivot table).

I tried to use the following code:

Sub Export_PivotTable()
Sheets("Table").PivotTables(1).PivotSelect "", xlDataAndLabel, True
Selection.Copy

Set New_Book = Workbooks.Add
New_Book.Sheets(1).Range("a1").Select
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
End Sub

However, it fails on line Selection.PasteSpecial

Paste:=xlPasteValues
(gives Error 1004: PasteSpecial method..failed)

What's wrong with my code?

Or maybe anybody knows a more elegant way to export a pivot table to a

plain
table without loosing the layout and formatting?

Thanks in advance -

RADO






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default How to export pivot table to a plain table?

Bernie -

thanks for your help! You identified my problem correctly. my best regards -

RADO


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
RADO,

Your copied table is lost when you add your workbook. You need to add
the workbook prior to the copying to allow the pasting.

See the code example below.

HTH,
Bernie
MS Excel MVP

Sub Export_PivotTable()

Dim New_Book As Workbook
Dim Old_Book As Workbook

Set Old_Book = ActiveWorkbook
Set New_Book = Workbooks.Add

Old_Book.Activate
Sheets("Table").Activate
ActiveSheet.PivotTables(1).PivotSelect "", xlDataAndLabel
Selection.Copy

New_Book.Activate
Sheets(1).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
End Sub


"RADO" wrote in message
...
Hi all,

I need some help. I have a pivot table, and I have to create it's

plain copy
in a new workbook, but preserving the layout (i.e., it should be a

plain
table looking exactly as the pivot table).

I tried to use the following code:

Sub Export_PivotTable()
Sheets("Table").PivotTables(1).PivotSelect "", xlDataAndLabel,

True
Selection.Copy

Set New_Book = Workbooks.Add
New_Book.Sheets(1).Range("a1").Select
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
End Sub

However, it fails on line Selection.PasteSpecial

Paste:=xlPasteValues
(gives Error 1004: PasteSpecial method..failed)

What's wrong with my code?

Or maybe anybody knows a more elegant way to export a pivot table to

a plain
table without loosing the layout and formatting?

Thanks in advance -

RADO






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I export a Pivot Table in Excel into Word? bananagirl Excel Worksheet Functions 0 May 24th 10 02:27 PM
Pivot Table link/export javablood Excel Discussion (Misc queries) 0 October 9th 09 03:44 PM
How do I export multiple lines of data from a pivot table? Pluff Excel Worksheet Functions 2 March 27th 09 01:12 AM
Export Pivot Table Data to Excel Table Milind Keer[_2_] Excel Discussion (Misc queries) 0 October 8th 08 04:53 PM
Can you export a pivot table into Access? Tracy Excel Discussion (Misc queries) 3 June 27th 07 12:41 AM


All times are GMT +1. The time now is 08:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"