Hi all,

I have the following task, writing a macro:
1. Copy a sheet.
2. Set all formulas as values.
3. Keep the pivot tables.

For points 1 and 2 I am ready.
Any ideas for point 3, using the following code:

        For Each wks In wbkTarget.Sheets
        
            With wks
    
                Set rRangeToCopy = Range(.Cells(1, 1), .UsedRange.Cells(.UsedRange.Cells.Count))
                vaDataValues = rRangeToCopy.Value
                rRangeToCopy.Value = vaDataValues
            
            End With
   
        Next wks
As you may guess, the problem is that when I use the code and I come to a cell in a Pivot table, it gives an error message. So I need a check at the beginning of the loop or something similar.
Ideas?