EXCEL 2013 VBA - Pragmatically add "(All)" to combo boxes to always be an option

ectiger86

Board Regular
Joined
Aug 27, 2014
Messages
67
I need to add "(All)" to always be an option for my 4 ActiveX dependent Combo Boxes. The Combo Boxes are populated by their Dynamic Named Ranges via VBA. Currently I have manually inserted (All) to be an option, but once the 1st combo boxes filter down (All) is no longer an option for the other combo's.

Any help would be greatly appreciated.

Here is my Fill code, It is pieced together from the internet.

Code:
Sub FillCombos()

    Dim CHART As Worksheet
    Dim DATA As Worksheet
    Set ch = ThisWorkbook.Sheets("CHART")
    Set da = ThisWorkbook.Sheets("DATA")
    
' Last Row
daLR = da.Cells(Rows.Count, 1).End(xlUp).Row
FirstTime = True

' Loop thru rows
For x = 2 To daLR
    If da.Cells(x, 1) <> "" And (InStr(blah, "|" & da.Cells(x, 1) & "|") = 0) Then
        If FirstTime = True Then
            FirstTime = False
         blah = "|" & blah & da.Cells(x, 1) & "|"
     Else
        blah = blah & da.Cells(x, 1) & "|"
    End If
End If
    

Next x

myArray = Split(blah, "|")

Sheet7.cmbRent.Clear

 For Each cell In myArray
    If cell <> "" Then
        Sheet7.cmbRent.AddItem (cell)
    End If
Next cell
      ThisWorkbook.Sheets("CHART").cmbRent.ListIndex = 0
   
   
   End Sub



And here is the code that changes my combos.


Code:
Option Explicit
Sub changeFilters()

    
    Dim pt As PivotTable
    Dim pf As PivotField
    Dim pi As PivotItem
    Dim wsChart As Worksheet
    Dim wsPivot As Worksheet
    Dim selCat  As Variant
    Dim selSub  As Variant
    Dim selLoc  As Variant
    Dim selCust As Variant
              
    
    Set wsChart = ThisWorkbook.Sheets("CHART")
    Set wsPivot = ThisWorkbook.Sheets("Pivot")
    Set pt = ThisWorkbook.Sheets("Pivot").PivotTables("PT1")
    Set selCat = ThisWorkbook.Sheets("CHART").Range("selCat")
    Set selSub = ThisWorkbook.Sheets("CHART").Range("selSub")
    Set selLoc = ThisWorkbook.Sheets("CHART").Range("selLoc")
    Set selCust = ThisWorkbook.Sheets("CHART").Range("selCust")
       
    
Application.ScreenUpdating = False
pt.ManualUpdate = True

ThisWorkbook.Sheets("Pivot").PivotTables("PT1").ClearAllFilters



For Each pi In pt.PivotFields("CATEGORY").PivotItems

    Select Case pi.Name
        Case [selCat]
            pi.Visible = True
        Case Else
            pi.Visible = False
        End Select
    Next pi


'Removes pivot items from pivot table except those cases defined below (by looping through)
For Each pi In pt.PivotFields("SUB-CATEGORY").PivotItems

    Select Case pi.Name
        Case [selSub]
            pi.Visible = True
        Case Else
            pi.Visible = False
        End Select
    Next pi



For Each pi In pt.PivotFields("LOCATION").PivotItems
    Select Case pi.Name
        Case [selLoc]
            pi.Visible = True
        Case Else
            pi.Visible = False
        End Select
    Next pi



For Each pi In pt.PivotFields("CUSTOMER").PivotItems
    Select Case pi.Name
        Case [selCust]
            pi.Visible = True
        Case Else
            pi.Visible = False
        End Select
    Next pi



'turn on automatic update / calculation in the Pivot Table

pt.ManualUpdate = False
Application.ScreenUpdating = True




End Sub
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,223,980
Messages
6,175,766
Members
452,668
Latest member
mrider123

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