Linda Crasco
New Member
Hello All,
I do a monthly report consisting of five data tables (each with different fields). A common element is the staff. Each month different members of the 20 member staff show up in different tables. For example, in June Joe may be in data tables 1, 2, 3, 4, and 5, but in July he may be only in data tables 3 and 4.
I have set up Pivot tables with slicers for each of the data tables.
The managers want to be able to filter for each member of the staff all at once. I have made macros and assigned them to buttons so when the manager clicks on the “Joe” button all five pivot tables filter for Joe.
The problem is each month I have to adjust my macro to add staff who are in a data table this month that they were not in last month, and delete staff from data tables that they were in last month, but not this month. I want to list all the possible staff in the macro, and have the macro skip the non applicable staff and resume. The on error resume command does not work.
Currently:
Sub Joe()
'
' Joe Macro
'
'
With ActiveWorkbook.SlicerCaches("Slicer_Data Table 1")
.SlicerItems("Howard").Selected = False
.SlicerItems("Jeffery").Selected = False
.SlicerItems("Mark").Selected = False
.SlicerItems("Marlene").Selected = False
.SlicerItems("Joe").Selected = True
.SlicerItems("Sharon").Selected = False
.SlicerItems("Steven").Selected = False
.SlicerItems("Mary").Selected = False
.SlicerItems("Tom ").Selected = False
.SlicerItems("Tim").Selected = False
End With
With ActiveWorkbook.SlicerCaches("Slicer_Data Table 2")
.SlicerItems("Howard").Selected = False
.SlicerItems("Lisa").Selected = False
.SlicerItems("Mark").Selected = False
.SlicerItems("Marlene").Selected = False
.SlicerItems("Joe").Selected = True
.SlicerItems("Sharon").Selected = False
.SlicerItems("Steven").Selected = False
.SlicerItems("Mary").Selected = False
End With
End Sub
Want:
With ActiveWorkbook.SlicerCaches("Slicer_Data Table 1")
.SlicerItems("Howard").Selected = False
.SlicerItems("Lisa").Selected = False (Lisa is not in Data Table 1 so macro skips Lisa and goes to Jeffrey)
.SlicerItems("Jeffery").Selected = False
.SlicerItems("Mark").Selected = False
.SlicerItems("Marlene").Selected = False
.SlicerItems("Joe").Selected = True
.SlicerItems("Sharon").Selected = False
.SlicerItems("Steven").Selected = False
.SlicerItems("Mary").Selected = False
.SlicerItems("Tom ").Selected = False
.SlicerItems("Tim").Selected = False
End With
With ActiveWorkbook.SlicerCaches("Slicer_Data Table 2")
.SlicerItems("Howard").Selected = False
.SlicerItems("Lisa").Selected = False
.SlicerItems("Jeffery").Selected = False (Jeffrey is not in Data Table 2 so macro skips Jeffery and goes to Mark)
.SlicerItems("Mark").Selected = False
.SlicerItems("Marlene").Selected = False
.SlicerItems("Joe").Selected = True
.SlicerItems("Sharon").Selected = False
.SlicerItems("Steven").Selected = False
.SlicerItems("Mary").Selected = False
.SlicerItems("Tom ").Selected = False (Tom is not in Data Table 2 so macro skips Tom and goes to Tim
.SlicerItems("Tim").Selected = False (Tim is not in Data Table 2 so macro skips Tim and goes to next Table 3 (not shown in example)
End With
End Sub
I hope I have explained it adequately. Thank you in advance for any help you can give me.
~Linda
I do a monthly report consisting of five data tables (each with different fields). A common element is the staff. Each month different members of the 20 member staff show up in different tables. For example, in June Joe may be in data tables 1, 2, 3, 4, and 5, but in July he may be only in data tables 3 and 4.
I have set up Pivot tables with slicers for each of the data tables.
The managers want to be able to filter for each member of the staff all at once. I have made macros and assigned them to buttons so when the manager clicks on the “Joe” button all five pivot tables filter for Joe.
The problem is each month I have to adjust my macro to add staff who are in a data table this month that they were not in last month, and delete staff from data tables that they were in last month, but not this month. I want to list all the possible staff in the macro, and have the macro skip the non applicable staff and resume. The on error resume command does not work.
Currently:
Sub Joe()
'
' Joe Macro
'
'
With ActiveWorkbook.SlicerCaches("Slicer_Data Table 1")
.SlicerItems("Howard").Selected = False
.SlicerItems("Jeffery").Selected = False
.SlicerItems("Mark").Selected = False
.SlicerItems("Marlene").Selected = False
.SlicerItems("Joe").Selected = True
.SlicerItems("Sharon").Selected = False
.SlicerItems("Steven").Selected = False
.SlicerItems("Mary").Selected = False
.SlicerItems("Tom ").Selected = False
.SlicerItems("Tim").Selected = False
End With
With ActiveWorkbook.SlicerCaches("Slicer_Data Table 2")
.SlicerItems("Howard").Selected = False
.SlicerItems("Lisa").Selected = False
.SlicerItems("Mark").Selected = False
.SlicerItems("Marlene").Selected = False
.SlicerItems("Joe").Selected = True
.SlicerItems("Sharon").Selected = False
.SlicerItems("Steven").Selected = False
.SlicerItems("Mary").Selected = False
End With
End Sub
Want:
With ActiveWorkbook.SlicerCaches("Slicer_Data Table 1")
.SlicerItems("Howard").Selected = False
.SlicerItems("Lisa").Selected = False (Lisa is not in Data Table 1 so macro skips Lisa and goes to Jeffrey)
.SlicerItems("Jeffery").Selected = False
.SlicerItems("Mark").Selected = False
.SlicerItems("Marlene").Selected = False
.SlicerItems("Joe").Selected = True
.SlicerItems("Sharon").Selected = False
.SlicerItems("Steven").Selected = False
.SlicerItems("Mary").Selected = False
.SlicerItems("Tom ").Selected = False
.SlicerItems("Tim").Selected = False
End With
With ActiveWorkbook.SlicerCaches("Slicer_Data Table 2")
.SlicerItems("Howard").Selected = False
.SlicerItems("Lisa").Selected = False
.SlicerItems("Jeffery").Selected = False (Jeffrey is not in Data Table 2 so macro skips Jeffery and goes to Mark)
.SlicerItems("Mark").Selected = False
.SlicerItems("Marlene").Selected = False
.SlicerItems("Joe").Selected = True
.SlicerItems("Sharon").Selected = False
.SlicerItems("Steven").Selected = False
.SlicerItems("Mary").Selected = False
.SlicerItems("Tom ").Selected = False (Tom is not in Data Table 2 so macro skips Tom and goes to Tim
.SlicerItems("Tim").Selected = False (Tim is not in Data Table 2 so macro skips Tim and goes to next Table 3 (not shown in example)
End With
End Sub
I hope I have explained it adequately. Thank you in advance for any help you can give me.
~Linda