Hello,
I am trying to write a macro that copies a Pivot Table and pastes it in a new sheet with the name "Table". I would also like to check if a sheet with the name "Table" already exists and overwrite it if it does. I have put my code below but I'm getting stuck on the line 11.
1 Sub PivotCopy()
2 Dim ws As Worksheet
3 Set ws = Worksheets.Add(after:=Sheets(Sheets.Count))
4 ws.Name = "Table"
5 Application.ScreenUpdating = False
6
7 Sheets("PivotTable").Select
8 ActiveSheet.PivotTables("PivotTable3").PivotSelect "", xlDataAndLabel, True
9 Selection.Copy
10 'Add code to check for tab with same name and overwite if there is
11 ws.Range("A1").PasteSpecial
12
13 Application.CutCopyMode = False
14 Application.ScreenUpdating = True
15 End Sub
Regards,
Tripp
I am trying to write a macro that copies a Pivot Table and pastes it in a new sheet with the name "Table". I would also like to check if a sheet with the name "Table" already exists and overwrite it if it does. I have put my code below but I'm getting stuck on the line 11.
1 Sub PivotCopy()
2 Dim ws As Worksheet
3 Set ws = Worksheets.Add(after:=Sheets(Sheets.Count))
4 ws.Name = "Table"
5 Application.ScreenUpdating = False
6
7 Sheets("PivotTable").Select
8 ActiveSheet.PivotTables("PivotTable3").PivotSelect "", xlDataAndLabel, True
9 Selection.Copy
10 'Add code to check for tab with same name and overwite if there is
11 ws.Range("A1").PasteSpecial
12
13 Application.CutCopyMode = False
14 Application.ScreenUpdating = True
15 End Sub
Regards,
Tripp