J
With ActiveSheet.PivotTables(1).DataBodyRange
y = .Rows.Count + .Cells(1, 1).Row - 2
End With
ActiveSheet.Cells(y, 3).ShowDetail = True
With ActiveSheet.PivotTables(1).DataBodyRange
y = .Rows.Count + .Cells(1, 1).Row - 2
Nom = ActiveSheet.Cells(y, .Column).Offset(0, -.Columns.Count).Value
ActiveSheet.Cells(y, .Column).ShowDetail = True
End With
ActiveSheet.Name = Nom
y = .Cells(1, 1).Row
Public Nom
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Nom = "" Then Exit Sub
Application.DisplayAlerts = False
Worksheets(Nom).Delete
Application.DisplayAlerts = True
End Sub