Fill combo or listbix with formula

rhombus4

Well-known Member
Joined
May 26, 2010
Messages
586
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Using below
I can fill combobox2, but when I try to use a variable or a value from a combobox or even a value from a textbox I can't get it to work
I get run time error 381

Excel Formula:
Combobox2.list = evaluate("filter(e2:E12, f2:f12 <> ""red"")")

Excel Formula:
Combobox3.list = evaluate("filter(e2:E12, f2:f12 <> myvar)")

Excel Formula:
Combobox4.list = evaluate("filter(e2:E12, f2:f12 <> combobox1.column(0))")

Excel Formula:
Combobox4.list = evaluate("filter(e2:E12, f2:f12 <> textbox1)")

Also would it be possible to load the formula to an array and fill with the array
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try:
VBA Code:
Combobox3.list = evaluate("filter(e2:E12, f2:f12 <> """ & myvar & """)")

Combobox4.list = evaluate("filter(e2:E12, f2:f12 <> """ & combobox1.Text & """)")

Combobox4.list = evaluate("filter(e2:E12, f2:f12 <> """ & textbox1.Text & """)")
 
Upvote 0
Thanks akuini. Easy when you know how.
Is this the best way to add via a formula if you don't want to add from a range within the book

Also would it be possible to load the formula to an array and fill with the array i e.

Combobox5.list = myarray
 
Upvote 0
Also would it be possible to load the formula to an array and fill with the array i e.
Try:
VBA Code:
myarray = evaluate("filter(e2:E12, f2:f12 <> """ & myvar & """)")
Combobox4.list = myarray
 
Upvote 0
Sorry me again.

After further testing It seems to work fine when filling from 1 column, however if the combo is 2 columns

Again it's fine if 2 results from evaluate e.g.
Red dog
Red cat

However if I only get one result from the evaluate it appears on 2 rows e.g
Red
Dog

Should appear as Red dog

Also get 381 error for no results
Formula using below
Excel Formula:
.list = evaluate("filter(e2:f12, f2:f12 <> """ & myvar & """)")
 
Upvote 0

Forum statistics

Threads
1,215,833
Messages
6,127,156
Members
449,366
Latest member
reidel

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