Forum Discussion
Pasting Pivot Table as Values... losing Borders and formatting
- Feb 17, 2018
Hi Brian,
There is a fairly good technique to paste the PivotTable values and formats, but it cost you some extra steps!
You can use the Format Painter to grab the format to the second instance of the PivotTable.
After you paste the PivotTable as values, go to the original PivotTable, highlight it, press Format Painter button, and then paint the second PivotTable!
Another method (Two levels Paste):
- Highlight the first PivotTable and copy it.
- Go to another location, and press Ctrl+Alt+V to open the Paste Special dialog box.
- Select Values and then hit OK.
- Press Ctrl+Alt+V again.
- Select Formats and then hit OK again!
Hi Brian,
There is a fairly good technique to paste the PivotTable values and formats, but it cost you some extra steps!
You can use the Format Painter to grab the format to the second instance of the PivotTable.
After you paste the PivotTable as values, go to the original PivotTable, highlight it, press Format Painter button, and then paint the second PivotTable!
Another method (Two levels Paste):
- Highlight the first PivotTable and copy it.
- Go to another location, and press Ctrl+Alt+V to open the Paste Special dialog box.
- Select Values and then hit OK.
- Press Ctrl+Alt+V again.
- Select Formats and then hit OK again!
- ViliDJan 15, 2020Copper ContributorIt do not work if you paste over the save plase. You paste as value but after paste as format is not possilbe any more.
- GaiNafiApr 03, 2019Copper Contributor
OMG you're brilliant !Haytham Amairah Finally my problem is settled using Format Painter. TQVM!
- Robert StenzSep 11, 2018Copper ContributorThis approach only works if going to "another location". It does not work if over writing the existing location using Office 2016 (365) and Mac OS. This issue only started when I recently switched from Excel 2011 to Excel 2016. Hopefully, there is a VBA solution of some sort. Thanks.
- Robert StenzSep 18, 2018Copper Contributor
Sept 18, 2018 - Here's VBA that copies values and formats for an entire sheet (including pivots) to a temporary sheet and saves that sheet as a new file with the same name as the tab. I'm a VBA hack, so any suggested improvements to this code are appreciated. Good luck and thanks in advance for any feedback on this coding.
Sub CopySheetsToFile()
'This macros copies the selected to sheet to a new sheet with similar formatting and with formulas/links/pivots removed
Dim SourceSheet As Worksheet
Dim TempSheet As Worksheet
Dim NewName As String
If MsgBox("Copy specific sheet to a new workbook" & vbCr & _
"New sheet will be pasted as values, named ranges removed" _
, vbYesNo, "NewCopy") = vbNo Then Exit Sub
With Application
.ScreenUpdating = False
' Modified - Original Source:http://www.vbaexpress.com/kb/getarticle.php?kb_id=359
' Copy active sheet
Set SourceSheet = ActiveWorkbook.ActiveSheet
' ***Insert new temporary sheet-per https://www.mrexcel.com/forum/excel-questions/607515-copy-paste-pivot-table-values-formatting.html
Set TempSheet = ThisWorkbook.Worksheets.Add
SourceSheet.Select
Cells.Select
Selection.Copy
TempSheet.[A1].PasteSpecial Paste:=xlPasteValues
SourceSheet.Select
Cells.Select
Selection.Copy
TempSheet.[A1].PasteSpecial Paste:=xlPasteFormats
Application.CutCopyMode = False
' File name equal to sheet name
TempSheet.Copy
NewName = SourceSheet.Name
' Formatting of TempSheet
Range("A1").Select
ActiveWindow.DisplayGridlines = False
ActiveWindow.Zoom = 70
ActiveSheet.Name = SourceSheet.Name
' Save it with the NewName and in the same directory as original
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\" & NewName & ".xlsx" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWorkbook.Close SaveChanges:=False
.ScreenUpdating = True
' ***Delete temporary Worksheet-This section may not be needed
Application.DisplayAlerts = False
TempSheet.Delete
Application.DisplayAlerts = True
Set TempSheet = Nothing
End With
Exit Sub
End Sub
' ***NOTE 1: This macro should be saved with the Workbook (vs Personal Macro Workbook) for the resulting new file to be saved in the original directory.
' ***NOTE 2: To work on a Mac, the above SaveAs command needs to be replaced by: ActiveWorkbook.SaveAs "Macintosh HD:Users:USERNAMEHERE:Desktop:DESKTOPFOLDERNAMEHERE:" & NewName & ".xlsx", FileFormat:=51
- Brian CatalanoFeb 20, 2018Copper ContributorThanks so much for your suggestions Haytham! I've modified my code to do just as you recommended (the 2nd method). Sad to see this one change though.... need to change my habits (maybe even just write a new macro) for hard-coding a pivot table!
- JKPieterseFeb 21, 2018Silver Contributor
I've had a look at various Excel versions I have at my disposal.
Excel 2003: Format is retained
Excel 2010: Format is lost
Excel 2013: Format is lost
Excel 2016 Monthly channel: Format is lost
Excel 2016 Insider fast: Format is lost
- Brian CatalanoFeb 21, 2018Copper Contributor
Haha, I'm not nuts! I can explain...
Most of my core files were created with Excel 2003. Copying them and opening them in whatever recent-version of Excel is on my system (I work at 3M and our Office editions are updated constantly).
So to test this, I got my old notebook out of my drawer.... opened my files and sure enough... I'm able to copy and paste-as-values OVER an existing PivotTable, and all formatting is retained as the PivotTable is overwritten with Values.
Old Computer Excel Version... 1705 (Build 8201.2213) Deferred Channel
New Computer Excel Version... 1708 (Build 8431.2153) Semi-Annual Channel
So clearly the newest build handles formatting differently for old files... aligning them to how you say Excel has behaved since at least the 2010 version. I don't expect this behavior to change, so I'll code my way around it... that's what makes Excel so great.... VBA.
Thanks ALL for your help,
Brian Catalano
- JKPieterseFeb 19, 2018Silver ContributorLooks like this "issue" has been in Excel for at least 6 years, as Excel 2010 also shows this behavior. So your workaround is the way to go.
- ken.wrightMar 06, 2018Copper Contributor
Hey Stranger :-) This only recently started happening to me also. Just "upgraded" to 365 at work, and this started happening. Was on 2013 prior to that and no issues. I have a little routine attached to a a key combo that hardwires whatever I have selected, and I do this a lot with Pivot tables. Been a major PITA for me.
Tried Debs' workaround from John W, of using the Office clipboard and found that I get different results if I do or don't have the Filters selected when i do the copy instead of just the table of values. Just strange.
That aside, I have to believe this was an unintended consequence of some other change in the code by the Devs, as surely no-one in their right mind would simply assume that this was a logical thing to do?
That aside, hope you are all well.
Regards
Ken.....................
- JKPieterseMar 07, 2018Silver ContributorHi Ken,
Nice to hear from you again.
What I find odd is that 2010 behaves the same as current 2016. Perhaps there is more involved than just a new version and this is related to some other update. Anyway, the work-around then is to copy the PT and paste it elsewhere. Painful, but it works.
- Brian CatalanoFeb 19, 2018Copper Contributor
Need to check Hayhams’s method proposed above.... but rest assured, we’ve been using the latest builds (updated automatically) and this just started this month for us.
- JKPieterseFeb 20, 2018Silver ContributorOK, thanks.