Excel VBA value of combo box different from the text -
i setting combo box update pivot table when selected. need value combo box return different value selected text.
ex. select products name in drop down box, "cheerios". has sku number of 1234. need combo box return 1234, , not word "cheerios".
is possible?
edit:
below image of getting list populated from. column b being displayed in drop down, column need returned when product selected.
edit 2:
private sub cmb_skuselect_click() dim xlsheetsort worksheet dim lastrow long dim skuvalue integer set xlsheetsort = activeworkbook.worksheets("sort") lastrow = xlsheetsort.range("a1").end(xldown).row xlsheetsort.range("b1:b" & lastrow) set c = .find(cmb_skuselect.value, lookin:=xlvalues) if not c nothing skuvalue = xlsheetsort.range("a" & c.row).value end if end cmb_skuselect.value = "" activeworkbook.activesheet.range("a4").value = skuvalue updatepivot skuvalue end sub
updatepivot:
public sub updatepivot(byval sku integer) dim xlsheet worksheet dim xlptable pivottable set xlsheet = activeworkbook.worksheets("sku inventory") each xlptable in xlsheet.pivottables xlptable .pivotfields("sku number").currentpage = sku end next end sub
try that:
private sub combobox1_change() dim valuetolook string valuetolook = combobox1.value dim sku, integer dim lastrow long activesheet lastrow = .cells(.rows.count, "b").end(xlup).row end = 1 lastrow if cells(i, 2).value = valuetolook sku = cells(i, 1).value msgbox sku exit end if next end sub
Comments
Post a Comment