excel - Populate ListBox on ComboBox selection - `run-time error '-2147352571 (80020005)':Type mismatch` -


i trying populate list box rows match combobox selection (in column a)

i keep getting error when reach record has match in worksheet run-time error '-2147352571 (80020005)':type mismatch

i trying search range matching values, add entire row of each matching value in column listbox, if there none, nothing. seems when there match, instead of copying row listbox, error.

my understanding if there no match, "" printed, if there match listbox3.additem sheets("actionitems").range("a2:c8").... combobox gets list different sheet within workbook.

private sub combobox3_change()     set rng = sheets("actionitems").range("a2:a50").find(what:=me.combobox3.value)     if rng nothing         listbox3.value = ""     else        listbox3.additem sheets("actionitems").range("a2:c8")   end if end sub 

on listbox.additem method written item data type string

so on examples on link, can have functions add itens end or beginning:

end:

function additemtoend(ctrllistbox listbox, _   byval stritem string)    ctrllistbox.additem item:=stritem   end function 

beginning:

function additemtobeginning(ctrlcombobox combobox, _   byval stritem string)    ctrlcombobox.additem item:=stritem, index:=0   end function 

it changes de index parameter

so @j.fox said, must make loop add them 1 one on loop e.g.:for each cell in range("a2:c8"): if cell <> "" listbox3.additem cell.text: next cell or array

and might better use exit instead of change

private sub combobox3_exit(byval cancel msforms.returnboolean) end sub 


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -