Copy multiple columns from pivot tabe (excluding last row) to new worksheet

wjeil

New Member
Joined
Feb 25, 2022
Messages
37
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a pivot table with 4 columns which I want to select the whole range and copy to another worksheet in (A2:D2 till the end of the row of the pivot table).

I have this code.
Dim rng As Range
Set rng = ActiveSheet.PivotTables("Draaitabel1").DataBodyRange
Set rng = rng.Resize(RowSize:=rng.Rows.Count - 1)
rng.Select

Which only selects the last column of the pivot table but excludes the last row. How can I copy all of the columns and copy them to a certain destination?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Because the pivot table is "foldable" my code gives the following result if i want to select the first 4 columns.

With ActiveSheet.PivotTables("Draaitabel1").DataBodyRange.Columns("A:D")
.Resize(RowSize:=.Rows.Count - 1).Select
End With

If i do it manually and copy only the values it works, so why does this command not selects column A:D like i say in the code?
 

Attachments

  • Example3.PNG
    Example3.PNG
    26.3 KB · Views: 4
Upvote 0
I figured out that the data in the first 3 columns (and the header) are labels (or rowlabels?) and that the ColliAmount in D are the values (or data)? Maybe it is better to select the whole pivot table, copy it as value and the delete the first and last row (so the header and the total at the end of the range). Am I correct?
 
Upvote 0

Forum statistics

Threads
1,214,968
Messages
6,122,509
Members
449,089
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top