+ Reply to Thread
Results 1 to 4 of 4

Copy and paste as values, except pivot tables

Hybrid View

thousand Copy and paste as values,... 12-29-2018, 04:39 AM
sktneer Re: Copy and paste as values,... 12-29-2018, 10:50 AM
thousand Re: Copy and paste as values,... 12-30-2018, 10:59 PM
sktneer Re: Copy and paste as values,... 12-30-2018, 11:34 PM
  1. #1
    Registered User
    Join Date
    01-23-2018
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    4

    Copy and paste as values, except pivot tables

    This works perfectly copying all formulas and pasting as values. However, I need a code to not copy pivot tables. Any suggestions?

    
    Sub AllValues()
    
    'Loop all worksheets in workbook
    
    Dim wSh As Worksheet
    For Each wSh In ActiveWorkbook.Worksheets
    
    'Copy
    
    With wSh.UsedRange
    .Copy
    
    'Paste
    
    .PasteSpecial xlPasteValues
    End With
    Next wSh
    
    Application.CutCopyMode = False
    End Sub
    Crosspost Excelguru

    Link supplied by mod: https://www.excelguru.ca/forums/show...T-pivot-tables

    Thanks
    Last edited by AliGW; 12-29-2018 at 08:39 AM.

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Copy and paste as values, except pivot tables

    Maybe this...

    Sub AllValues()
    Dim wSh As Worksheet
    Dim aCell As Range
    Dim pt As PivotTable
    For Each wSh In ActiveWorkbook.Worksheets
        For Each aCell In wSh.UsedRange
            On Error Resume Next
            Set pt = aCell.PivotTable
            On Error GoTo 0
            If pt Is Nothing Then aCell.Value = aCell.Value
            Set pt = Nothing
        Next aCell
    Next wSh
    End Sub
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Registered User
    Join Date
    01-23-2018
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    4

    Re: Copy and paste as values, except pivot tables

    Thanks sktneer, appreciate your reply and help.

    I have 10+ worksheets to copy and paste as values. I wonder if there is any quicker and faster way by slightly adjusting the codes.

    Thanks

    Quote Originally Posted by sktneer View Post
    Maybe this...

    Sub AllValues()
    Dim wSh As Worksheet
    Dim aCell As Range
    Dim pt As PivotTable
    For Each wSh In ActiveWorkbook.Worksheets
        For Each aCell In wSh.UsedRange
            On Error Resume Next
            Set pt = aCell.PivotTable
            On Error GoTo 0
            If pt Is Nothing Then aCell.Value = aCell.Value
            Set pt = Nothing
        Next aCell
    Next wSh
    End Sub

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Copy and paste as values, except pivot tables

    Maybe this...

    Sub AllValues()
    Dim wSh As Worksheet
    Dim aCell As Range
    
    For Each wSh In ActiveWorkbook.Worksheets
        For Each aCell In wSh.UsedRange.SpecialCells(xlCellTypeFormulas)
            aCell.Value = aCell.Value
        Next aCell
    Next wSh
    MsgBox "Finished"
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 06-26-2017, 12:49 AM
  2. Empty values in pivot chart changed to zero after copy/paste
    By krong in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 12-30-2014, 08:58 PM
  3. [SOLVED] Copy Column in pivot table and paste values
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-26-2014, 09:32 AM
  4. How-to Copy and Paste Values from list into Pivot Table filter
    By MacroNerd in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-05-2013, 06:26 PM
  5. VBA - copy a sheet, setting formulas to values and keeping Pivot tables
    By kaligad in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-27-2013, 09:15 AM
  6. [SOLVED] copy pivot, paste Values and borders
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-06-2010, 05:03 PM
  7. Excel 2007 : Paste Special Values for Pivot Tables
    By PaulTaylor in forum Excel General
    Replies: 16
    Last Post: 08-11-2009, 05:07 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1