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
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