Pivot table sorting

Code Chaser

New Member
Joined
Nov 23, 2016
Messages
8
I want to sort by a specific pivot table column, ultimately to copy and past the copied column into a new worksheet. This needs to happen for memo line A B and C. The column is called "Memo" and contains memo line A,B,C and N/A.

Problem: I want to deselect all pivot table items then make the variable MemoItem visible.

Could someone please explain to me what the FilterHelp variable is doing right now? and what do I need to do to solve my problem?

Thank you for the help.




'Include A, exclude B, C and N/A
Sheets("pivot by account and memo col").Select
With ActiveSheet.PivotTables("Recon Pivot").PivotFields("Memo")

Dim Memoitem As String
Dim i As Integer
For i = 1 To 3
If i = 1 Then
Memoitem = "A"
End If
If i = 2 Then
Memoitem = "B"
End If
If i = 3 Then
Memoitem = "C"
End If

Dim FilterHelp As Integer
On Error GoTo ErrorHandler2
.PivotItems(Memoitem).Visible = True
On Error GoTo 0
For FilterHelp = 2 To .PivotItems.Count
Sheets("pivot by account and memo col").Select
With ActiveSheet.PivotTables("Recon Pivot").PivotFields("Memo")
.PivotItems(FilterHelp-1).Visible = False 'Doesnt work right now, no idea why
On Error GoTo ErrorHandler2
.PivotItems(Memoitem).Visible = True
On Error GoTo 0
End With
Next FilterHelp
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,214,806
Messages
6,121,672
Members
449,045
Latest member
Marcus05

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