Paste Formats Pivot Table 2007

graphage

Board Regular
Joined
Mar 7, 2002
Messages
87
I have a pivot table w/ 20 columns. I have a macro that adds a column in Column 21 and inserts a column heading and necessary calculations. That works fine.

However, I then highlight the 20th column and try to paste the formats into Column 21 and it doesn't work. I do it manually and it works fine. I do it manually and record a macro and it works fine...I run the macro...it doesn't work.

Here's the part of my code that copies and pastes....Any ideas? Is this a glitch in Excel 2007?

Range(Cells(11, Sheets("notes").Range("C4").Value), Cells(Bottom + 1, Sheets("notes").Range("C4").Value)).Select
Selection.Copy
Sheets("Report").Range(Cells(11, RightEdge + 1), Cells(Bottom + 1, RightEdge + 1)).Select
Selection.PasteSpecial Paste:=xlPasteFormats
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
An update:

When I directly select (via VBA) the range, it works fine w/ VBA, For example:
Range("W11:W25").Copy
Range("X11:X25").PasteSpecial xlPasteFormats


I tried this and it doesn't work(it highlights and copies as requested, but does not paste anything):
Columns(23).Copy
Columns(24).PasteSpecial xlPasteFormats
 
Upvote 0
GOT IT!

I always like to overshoot my ranges just to ensure I have it all...usually by one row on either side. For some reason with the pivot table it didn't like that, I stopped overshooting and just selected the exact range from the Pivot to copy and it pasted fine.

Range(Cells(11, RightEdge), Cells(Bottom, RightEdge)).Copy
Range(Cells(11, RightEdge + 1), Cells(Bottom, RightEdge + 1)).PasteSpecial xlPasteFormats


I took out the "Bottom +1" and just made it "Bottom"...that cleared it up!
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,199
Members
449,072
Latest member
DW Draft

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