Populate Combo Box Based on Table Field

BrittKnee

Board Regular
Joined
Dec 4, 2017
Messages
82
Hi. I am trying to populate a combo box based on a field in a table. I am using the below code, but it is not populating. Any help is appreciated.

Code:
Private Sub DeptCombo_Change()

Dim ws, wsht As Worksheet
Dim rng As Range

'Populate Combo Box

  Set ws = Sheets("Readiness_All")
  Set wsht = Sheets("Dept_Selection")
  Set rng = Range("Readiness[Department]")

wsht.DeptCombo.List = ws.rng.Value

End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
I've decided to nix the combo box and would like to filter the table based on the selection in a drop-down list. I am using the below code, but it's not working. TIA!

Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = Range("Filtervalue").Address Then
Range("Readiness").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("Readiness[Department")
End If
End Sub
 
Upvote 0
I've decided to nix the combo box and would like to filter the table based on the selection in a drop-down list. I am using the below code, but it's not working. TIA!

Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = Range("Filtervalue").Address Then
Range("Readiness").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("Readiness[Department")
End If
End Sub

This works:

Code:
Option Explicit


Private Sub Worksheet_Change(ByVal Target As Range)


Dim ws As Worksheet

    Set ws = Sheets("Readiness_All")

    With Me
        If Not Intersect(Target, .Range("FilterValue")) Is Nothing Then
          If Target.Value <> "" Then
                .AutoFilterMode = False
                .Range("Readiness").AutoFilter Field:=7, Criteria1:=Target.Value
        End If
      End If
        
    End With


End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,069
Messages
6,122,952
Members
449,095
Latest member
nmaske

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