Macro for Copying and pasting pivots but how do i format?

Siro1

New Member
Joined
Jun 13, 2017
Messages
2
Hello,

I have created a macro that pulls numerous pivots into a new tab - in the new page the values seem to be coming across as paste 123 ( no formatting). I want to add some colors so i was going to color the pivots and let the macro pull across the data and formatting. To do this i thought the paste value transpose was best to do this but i haven't been able to get this working.

Here is the Code

Sub Button2_Click()



Dim ws As Worksheet
Set ws = Worksheets.Add
ws.Name = "pivot test"
Dim Last_Row As Long
Last_Row = Range("A" & Rows.Count).End(xlUp).Row

Sheets("Ordered Pivot").Select
ActiveSheet.PivotTables("PivotTable2").PivotSelect "", xlDataAndLabel, True
Selection.Copy

ws.Range("A1").PasteSpecial xlPasteValues

I also added this code in to fit the data correctly into columns

Application.ScreenUpdating = False
Dim wkSt As String
Dim wkBk As Worksheet
wkSt = ActiveSheet.Name
For Each wkBk In ActiveWorkbook.Worksheets
On Error Resume Next
wkBk.Activate
Cells.EntireColumn.AutoFit
Next wkBk
Sheets(wkSt).Select
Application.ScreenUpdating = True


Any thoughts?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
As you hinted, you are not copying Pivot Tables. You are copying the values.
Formatting. So many options, but to use any of the PivotTable Styles or Pivot Table formatting, you need to have Pivot Tables.
Are you trying to create new PivotTables for new data in a "new" Workbook?
Why do you need to "copy" the Pivot Tables?
 
Upvote 0
As you hinted, you are not copying Pivot Tables. You are copying the values.
Formatting. So many options, but to use any of the PivotTable Styles or Pivot Table formatting, you need to have Pivot Tables.
Are you trying to create new PivotTables for new data in a "new" Workbook?
Why do you need to "copy" the Pivot Tables?

well there is source data that is that feeds into pivots per location - I'm just pulling a copy of the pivots to provide a monthly snapshot as each month the values will change. I'm just looking to add some color as the final piece of the puzzle.

As there is so many options I'm just looking for the easiest - any ideas? i was thinking to pre-color the pivots and copy them across. I haven't been able to do this thus far
 
Upvote 0

Forum statistics

Threads
1,213,560
Messages
6,114,306
Members
448,564
Latest member
ED38

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