AndrewPaulCooper
New Member
I have one table of information containing Business, Site, Room and associated usage and date data.
This generates a single pivot table (Starting in cell AA1 so out of sight of the end users)
Which produces a chart from that pivot showing the data
The chart and the table are on one tab so I can move the slicers over the chart and create a dashboard effect.
I have three linked slicers;
1st showing Business
2nd showing Sites
3rd showing Rooms
I have some VBA code to capture which slicers have been pressed and display that in the chart title ~ so far so good.
Assuming all filters are unset and someone presses {site 4} only (skipping the top slicer) then
The business slicer correctly shows which businesses have a presence on those sites (They are in a dark blue colour and ordered at the top of the pile)
The Room slicer correctly shows which sites have a room on those sites (Again they are in a dark blue colour and ordered at the top of the pile)
However (and finally we are at the point of the question) the title wrongly shows All BG's site 4 all room's i.e. the code has not detected the shades of colour it only detects a pressed (or multiple pressed) options (where the colours are blue or white, not dark blue and light blue).
I have not initially included the spread sheet as it has 373 lines of real data and it would take an age to make it into demo data.
How do I update the code to show the inferred [dark blue] selections?
My code is;
The chart title links to cell N4 which has this code;
This generates a single pivot table (Starting in cell AA1 so out of sight of the end users)
Which produces a chart from that pivot showing the data
The chart and the table are on one tab so I can move the slicers over the chart and create a dashboard effect.
I have three linked slicers;
1st showing Business
2nd showing Sites
3rd showing Rooms
I have some VBA code to capture which slicers have been pressed and display that in the chart title ~ so far so good.
Assuming all filters are unset and someone presses {site 4} only (skipping the top slicer) then
The business slicer correctly shows which businesses have a presence on those sites (They are in a dark blue colour and ordered at the top of the pile)
The Room slicer correctly shows which sites have a room on those sites (Again they are in a dark blue colour and ordered at the top of the pile)
However (and finally we are at the point of the question) the title wrongly shows All BG's site 4 all room's i.e. the code has not detected the shades of colour it only detects a pressed (or multiple pressed) options (where the colours are blue or white, not dark blue and light blue).
I have not initially included the spread sheet as it has 373 lines of real data and it would take an age to make it into demo data.
How do I update the code to show the inferred [dark blue] selections?
My code is;
Code:
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
Dim NumItems As Integer, counter As Integer
NumItems = Me.PivotTables(1).Slicers("str_BusinessGroup").SlicerCache.SlicerItems.Count
outputstring = vbNullString
counter = 0
For Each slcritm In Me.PivotTables(1).Slicers("str_BusinessGroup").SlicerCache.SlicerItems
If slcritm.Selected Then
counter = counter + 1
outputstring = outputstring & ", " & slcritm.Name
End If
Next
If counter = NumItems Then
outputstring = "All BG's"
Else
outputstring = Mid(outputstring, 2, 999)
End If
Range("N1").Value = outputstring
NumItems = Me.PivotTables(1).Slicers("str_Site").SlicerCache.SlicerItems.Count
outputstring = vbNullString
counter = 0
For Each slcritm In Me.PivotTables(1).Slicers("str_Site").SlicerCache.SlicerItems
If slcritm.Selected Then
counter = counter + 1
outputstring = outputstring & ", " & slcritm.Name
End If
Next
If counter = NumItems Then
outputstring = "All Sites's"
Else
outputstring = Mid(outputstring, 2, 999)
End If
Range("N2").Value = outputstring
NumItems = Me.PivotTables(1).Slicers("str_RoomName").SlicerCache.SlicerItems.Count
outputstring = vbNullString
counter = 0
For Each slcritm In Me.PivotTables(1).Slicers("str_RoomName").SlicerCache.SlicerItems
If slcritm.Selected Then
counter = counter + 1
outputstring = outputstring & ", " & slcritm.Name
End If
Next
If counter = NumItems Then
outputstring = "All Room's"
Else
outputstring = Mid(outputstring, 2, 999)
End If
Range("N3").Value = outputstring
End Sub
The chart title links to cell N4 which has this code;
Code:
=N1&" "&N2&" "&N3