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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
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,223,888
Messages
6,175,213
Members
452,618
Latest member
Tam84

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