VBA to skip part of the macro if there is an error

daves120

New Member
Joined
Apr 22, 2015
Messages
17
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
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top