excel - Userform listbox rowsource not populating -
i have userform ok , cancel button , listbox. supposed populate using code:
private sub userform_initialize() me.startupposition = 0 me.top = application.top + (application.height / 2) - (me.height / 2) me.left = application.left + (application.width / 2) - (me.width / 2) me.listbox1 .rowsource = "" .columncount = 7 .columnwidths = "80;100;20;1;20;1;1000" .rowsource = sheets("boh database").range("h9:n14").address ' .rowsource = sheets("boh database").range("h9:n" & sheets("boh database").range("a65536").end(xlup).row - 1).address end end sub neither rowsource statements work. have tried clearing rowsource before filling again. doing wrong?
edit: i've added code have here doesn't show in comment: i'm using code based on yours , it's crashing sheet:
with me.listbox1 .columncount = 7 .columnwidths = "80;100;20;1;20;1;1000" .rowsource = "'" & sheets("boh database").name & "'!" & sheets("boh database") _ .range("h9:n" & sheets("boh database").range("a65536").end(xlup).row - 1).address end
that incorrect way it. syntax is
listbox1.rowsource = "sheetname!rangeaddress" so if sheet name sheet1 above becomes
listbox1.rowsource = "sheet1!h9:n14" also since sheet name has space, have add ' before , after sheet name.
try this
listbox1.rowsource = "'boh database'!h9:n14" or in way...
with sheets("boh database") listbox1.rowsource = "'" & .name & "'!" & .range("h9:n14").address end
Comments
Post a Comment