excel - Userforms with a listbox in VBA -
this first post on forum. have quick question regarding vba, userforms listbox. goal select 2 options , return list of names in listbox. have attached example userform , example table choosing from. appreciated.
private sub listbox1_click() sheets("trainers1").range("i2") = listbox1 end sub private sub listbox2_click() sheets("trainers1").range("i2") = listbox2 end sub private sub listbox3_click() sheets("trainers1").range("i3") = listbox3 end sub private sub listbox4_change() .listbox4 = sheets("trainers1").range("k2:k10") end sub private sub userform_initialize() dim cnt dim cntr integer cntr = application.worksheetfunction.counta(sheets("shift pattern key").range("a:a")) cnt = application.worksheetfunction.counta(sheets("training ratio").range("a:a")) = 2 cntr listbox2.additem sheets("shift pattern key").cells(i, 1) next i2 = 2 cnt listbox3.additem sheets("training ratio").cells(i2, 1) next i2 end sub
you iterate through rows of table , compare values in each row values selected. if both values in row match values selected user can use .additem method add name of employee list.
Comments
Post a Comment