combo box.

dcmb

Board Regular
Joined
Feb 3, 2009
Messages
116
I googled but couldn't find an answer.

I'm still pretty new to VBA. And I want to use a combo box / list box to show the items in a column which I can select.

For example:

HTML:
         A
1     apple
2     orange
3     apple
4     banana

I want the combo box / list box to show the list of items in column A. And say, I select orange on the combo box / list box then I want to use the selected data for filtering.

All suggestions and ideas are welcomed.

Thanks in advance.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Why VBA for this ??
You could simply Auto Filter column "A" and select "Orange" from the Auto Filter list
 
Upvote 0
Why VBA for this ??
You could simply Auto Filter column "A" and select "Orange" from the Auto Filter list

Hi Michael.

I'm working on something to allow my team mates input what they want to filter and then use the the selections to perform other things.

And I have only used command buttons but never use combo box / list box before so would also like to take the opportunity to learn about them.
 
Upvote 0
Hi Michael.

I'm working on something to allow my team mates input what they want to filter and then use the the selections to perform other things.

And I have only used command buttons but never use combo box / list box before so would also like to take the opportunity to learn about them.


I tried the following codes but got an error type mismatch at "cbblist = Sheets("sheet2").Range("i:i")".

Code:
    Dim cbblist As String
    
    cbblist = Sheets("sheet2").Range("i:i")
    Sheets("sheet1").cbb1.ListFillRange = "=cbblist"

anyone can help with the error or have any better suggestions?

Thanks.
 
Upvote 0
I tried the following codes but got an error type mismatch at "cbblist = Sheets("sheet2").Range("i:i")".

Code:
    Dim cbblist As String
    
    cbblist = Sheets("sheet2").Range("i:i")
    Sheets("sheet1").cbb1.ListFillRange = "=cbblist"

anyone can help with the error or have any better suggestions?

Thanks.


I managed to solve the error by removing "As String", i.e. simply "Dim cbblist".

I stepped through the codes without any errors but nothing appear on my combo box. Anyone can help please?

Thanks.
 
Upvote 0
Can you post all of the code ?
Range ("i:i") means nothing in the context of what you are trying to do
 
Upvote 0
Hi Michael,

that's all the code I have for now... I'm trying to get the combo box to show the items available in the entire column I.

Thanks.
 
Upvote 0
How many rows does cbblist use ?
Are the sheets "sheet1"...in lower case.....normally they are Proper
 
Upvote 0
The number of rows is not fixed. That's why I use the entire column "i:i".

Yes, sheet1 is in lower case.

Thanks.
 
Upvote 0
Try
Code:
Dim cbblist As String, lr As Long
lr = Cells(Rows.Count, "I").End(xlUp).Row
cbblist = Sheets("sheet2").Range("I1:I" & lr)
Sheets("sheet1").cbb1.ListFillRange = "=cbblist"
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,585
Members
448,972
Latest member
Shantanu2024

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