Hi folks,
This macro is to filter a pivot table and I would like to add to it. The macro is part of a series and would like to amend it to copy and paste the filtered data onto another tab in the workbook
The problem arises if there is not a site (a physical location) in the data dump that contains the people associated with a site., then the list is not filtered and all the data is copied and pasted onto another tab. I tried adding the copy and paste values macros into this one, but still get the whole list.
Any guidance would be greatly appreciated.
Sub FilterFTEPivot()
Dim pt As PivotTable
Dim pf As PivotField
Set pt = wsFTEPT.PivotTables("PivotTable3")
'Application.ScreenUpdating = False
On Error Resume Next
wsFTEPT.Select
With Selection
pt.PivotFields("Position Country").ClearAllFilters
pt.PivotFields("Position Country").CurrentPage = Range("Site").Value
End With
ActiveWorkbook.RefreshAll
'Insert the macro that tells it to skip this section
wsFTEs.Select
Range("A4").Select
Range(Selection, Selection.End(xlDown)).ClearContents
wsFTEPT.Select
Range("A4").Select
Range(Selection, Selection.End(xlDown)).Copy
wsFTEs.Select
Range("A4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A1").Select
End If
With wsControl
.Activate
.Range("A1").Activate
End With
End Sub
This macro is to filter a pivot table and I would like to add to it. The macro is part of a series and would like to amend it to copy and paste the filtered data onto another tab in the workbook
The problem arises if there is not a site (a physical location) in the data dump that contains the people associated with a site., then the list is not filtered and all the data is copied and pasted onto another tab. I tried adding the copy and paste values macros into this one, but still get the whole list.
Any guidance would be greatly appreciated.
Sub FilterFTEPivot()
Dim pt As PivotTable
Dim pf As PivotField
Set pt = wsFTEPT.PivotTables("PivotTable3")
'Application.ScreenUpdating = False
On Error Resume Next
wsFTEPT.Select
With Selection
pt.PivotFields("Position Country").ClearAllFilters
pt.PivotFields("Position Country").CurrentPage = Range("Site").Value
End With
ActiveWorkbook.RefreshAll
'Insert the macro that tells it to skip this section
wsFTEs.Select
Range("A4").Select
Range(Selection, Selection.End(xlDown)).ClearContents
wsFTEPT.Select
Range("A4").Select
Range(Selection, Selection.End(xlDown)).Copy
wsFTEs.Select
Range("A4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A1").Select
End If
With wsControl
.Activate
.Range("A1").Activate
End With
End Sub