• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Pivot table rename

Pinang

Member
Hi,

Is there a way we can rename pivot table name on basis of active cell?

For example, I have a pivot starting from cell A1 and I want to copy that pivot to cell F1 and rename it using VBA without using reference PivotTables("PivotTable1").
 
Sure.

Ex:
Code:
Sub Demo()
Dim pvt As PivotTable
On Error GoTo ErrHandle:
Set pvt = ActiveCell.PivotTable
pvt.TableRange2.Copy Range("F1")

With Range("F1").PivotTable
    .Name = "New Name"
End With
ErrHandle:
If Err.Number <> 0 Then
    MsgBox "You must select pivot table range. Or you must change destination range to avoid range overlap"
End If
   
End Sub
 
Back
Top