excel vba - Filter the list in a combox in vba form as you type -


i have problem on how apply filter in combo box , requiry records.

i using combo box named customers contains names of customers (approx 3000) array called settings.customerarray

i want shrink list automatically type text in combo box, idea adapt this method somehow achieve want. not working code looks this, not refresh form correctly.

private sub project_comboboxcustomer_change()     dim e, temp     me         temp = .project_comboboxcustomer.value         if not .project_comboboxcustomer.matchfound             .project_comboboxcustomer.clear             if len(temp)                 each e in cpearson.getcolumnfrom2darray(settings.prosjektcustomerarray, 1)                     if (e <> "") * (e "*" & temp & "*")                         .project_comboboxcustomer.additem e                     end if                 next                 if .project_comboboxcustomer.listcount > 0                     .project_comboboxcustomer.listindex = 0                 end if             end if         end if     end end sub 

does have routine similar problem form in vba(i need work both in excel , word, hence using array , not range in excel sheet), or suggestion how can improve current algorithm.

here code getcolumnfrom2darray in case needs it., returns 1 dimensional array 2 dimensional array:

function getcolumnfrom2darray(arr variant, columnnumber long) string()     ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''     ' getcolumn     ' populates resultarr one-dimensional array     ' specified column of arr. existing contents of resultarr     ' destroyed. resultarr must dynamic array.     ' returns true or false indicating success.     ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''     dim rowndx long     dim resultarr() string     ''''''''''''''''''''''''''''''     ' ensure arr array.     ''''''''''''''''''''''''''''''     if isarray(arr) = false         getcolumnfrom2darray = array()         exit function     end if      ''''''''''''''''''''''''''''''''''     ' ensure arr two-dimensional     ' array.     ''''''''''''''''''''''''''''''''''     if numberofarraydimensions(arr) <> 2         getcolumnfrom2darray = array()         exit function     end if       ''''''''''''''''''''''''''''''''''''     ' ensure columnnumber less     ' or equal number of columns.     ''''''''''''''''''''''''''''''''''''     if ubound(arr, 2) < columnnumber         getcolumnfrom2darray = array()         exit function     end if      if lbound(arr, 2) > columnnumber         getcolumnfrom2darray = array()         exit function     end if       redim resultarr(lbound(arr, 1) ubound(arr, 1))     rowndx = lbound(resultarr) ubound(resultarr)         resultarr(rowndx) = arr(rowndx, columnnumber)     next rowndx      getcolumnfrom2darray = resultarr end function 


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -