excel - Having trouble with syntax for populating listbox -
i'm beginner programmer , making vba macro senior capstone project. i'm trying populate listbox data in "a column". must dynamic, because user edit data. know simple seasoned coder, i'm having problems syntax. appreciated!
private sub userform_initialize() dim lastrowcontrollers, lastrowbrakes integer dim brakes, controllers range worksheets("controllersinventory") lastrowcontrollers = .cells(.rows.count, "a").end(xlup).row end worksheets("brakesinventory") lastrowbrakes = .cells(.rows.count, "a").end(xlup).row end set controllers = range(cells(1, 1), cells(lastrowcontrollers, 1)) set brakes = range(cells(1, 1), cells(lastrowbrakes, 1)) 'populate controller_list worksheets("controllerinventory").select controller_list .rowsource "= controllers" end 'populate brake_list worksheets("brakeinventory").select brake_list .rowsource "= brakes" end end sub
i found alternative way populating listboxes, syntax wrong , use proper coding techniques using declared ranges.
brake_list.rowsource = worksheets("brakeinventory").range(cells(1, 1), cells(lastrowcontrollers, 1)).address
for example:
dim rws long, rng range rws = cells(rows.count, "a").end(xlup).row set rng = range(cells(1, 1), cells(rws, 1)) listbox1.list = rng.value
Comments
Post a Comment