Populate Activex Combo box list from another sheet list

sanket_sk

Board Regular
Joined
Dec 27, 2016
Messages
140
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I am working on Activex Combobox which is located in "Dashboard" sheet wherein I want to display dynamic range from another sheet called "Filters"

I have created the dynamic range in "Filters" A Column using the Filter function.

Also, I have VBA (pasted below) but this VBA is referencing in "Dashboard" sheet whereas i want it from Filter Sheet, is there any trick which we can use to populate data.

Dashboard Latest .xlsm
A
1Region
2East
3North
4South
5West
Filters
Cell Formulas
RangeFormula
A2:A5A2=SORT(UNIQUE(FILTER(ASC_List[Region],ASC_List[Region]=ASC_List[Region])),)
Dynamic array formulas.



Private Sub Region_L_Change()

Dim Rng As Range

Set Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
Region_L.ListFillRange = Rng.Address
Region_L.ListIndex = 0

End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
How about ...
VBA Code:
Private Sub Region_L_Change()

    Dim Ws  As Worksheet
    Dim Rng As Range

    Set Ws = ThisWorkbook.Sheets("Filters")
    With Ws
        Set Rng = .Range(.Range("A2"), .Range("A" & .Rows.Count).End(xlUp))
    End With
    
    Region_L.ListFillRange = Rng.Address
    Region_L.ListIndex = 0

End Sub
 
Upvote 0
How about
VBA Code:
Private Sub Region_L_Change()

Dim Rng As String

Rng = Sheets("Filters").Range("A2#").Address(, , , 1)
Region_L.ListFillRange = Rng
Region_L.ListIndex = 0

End Sub
 
Upvote 0
How about ...
VBA Code:
Private Sub Region_L_Change()

    Dim Ws  As Worksheet
    Dim Rng As Range

    Set Ws = ThisWorkbook.Sheets("Filters")
    With Ws
        Set Rng = .Range(.Range("A2"), .Range("A" & .Rows.Count).End(xlUp))
    End With
   
    Region_L.ListFillRange = Rng.Address
    Region_L.ListIndex = 0

End Sub
Hi GWteB,

I tried this code, but the Combobox is not showing a list then I go back to code and run manually where system is trowing below error, please suggest..

1625488330626.png


Thanks,
Sanket
 
Upvote 0
Rng.Address evaluates to something like $A$1:$A$3 but you need a fully specified name, like in
VBA Code:
"'[Book.xlsm]filters'!$A$1:$A$3"

I suggest you better use Fluff's code since you have Excel 365. Fluff's code provides a fully specified name.
 
Upvote 0
How about
VBA Code:
Private Sub Region_L_Change()

Dim Rng As String

Rng = Sheets("Filters").Range("A2#").Address(, , , 1)
Region_L.ListFillRange = Rng
Region_L.ListIndex = 0

End Sub
Hi Fluff,

Thanks for the code, it is working fine, i can see desired list in combobox however, i am unable to select different regions, seems the code is getting reset every time i click/select the region.

Is there any trick by which we can control the resetting of the code?

Just to inform you, i am creating dependent combobox of Branch, City and so on using same code hence looking for control of the behaviour.

1625490923437.png



Sanket
 
Upvote 0
I'm afraid I don't understand what you mean when you say it's resetting.
 
Upvote 0
I'm afraid I don't understand what you mean when you say it's resetting.
Ok, SO Combobox is showing a list, on top of the list is East region

1625492376104.png


When click on North, West or South - combo boxt is again showing East only. (Unable to selet any value other that east)

Just to cross check combobox i removed VBA code and given hard coded range (Same range which VBA is returing), hard coded range is working fine i am able to select required region, i dont know what went wrong when i use VBA in combobox

1625492465595.png


Sanket
 
Upvote 0
Ok, remove this line
VBA Code:
Region_L.ListIndex = 0
 
Upvote 0
Solution

Forum statistics

Threads
1,214,625
Messages
6,120,598
Members
448,973
Latest member
ksonnia

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