Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listbox
Hi everyone,
I have a listbox on a userform, that I created from the control toolbox, that appears when a user changes the selection on a combo box. I can get the form to appear with the listbox when the combobox is changed, but I can't get the list box to populate with the info. The data that populates the list box is named with a dynamic range. If I put the listbox directly onto the worksheet, I can get it to fill with the listrangefill property with code I wrote, but when I put it onto the userform I can't get it to fill. I tried changing the code to the rowsorce property but that didn't work for me. Can someone provide the code I need to have the listbox fill when the user form is opened? Thanks, Scott |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listbox
post your rowsource attempt code
"Scott J" wrote: Hi everyone, I have a listbox on a userform, that I created from the control toolbox, that appears when a user changes the selection on a combo box. I can get the form to appear with the listbox when the combobox is changed, but I can't get the list box to populate with the info. The data that populates the list box is named with a dynamic range. If I put the listbox directly onto the worksheet, I can get it to fill with the listrangefill property with code I wrote, but when I put it onto the userform I can't get it to fill. I tried changing the code to the rowsorce property but that didn't work for me. Can someone provide the code I need to have the listbox fill when the user form is opened? Thanks, Scott |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listbox
Here it is:
dim listbox As Long listbox = Sheets Data("data 3").range("an4:an500").end(xlUp).row with worksheets("Item Tracker").listbox1 ..ControlSource = Worksheet("data 3").range("listbox").address(external:=True) End With I am relatively new to coding so try not to be to brutal on me. Thanks, Scott J "Vacation's Over" wrote: post your rowsource attempt code "Scott J" wrote: Hi everyone, I have a listbox on a userform, that I created from the control toolbox, that appears when a user changes the selection on a combo box. I can get the form to appear with the listbox when the combobox is changed, but I can't get the list box to populate with the info. The data that populates the list box is named with a dynamic range. If I put the listbox directly onto the worksheet, I can get it to fill with the listrangefill property with code I wrote, but when I put it onto the userform I can't get it to fill. I tried changing the code to the rowsorce property but that didn't work for me. Can someone provide the code I need to have the listbox fill when the user form is opened? Thanks, Scott |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listbox
OK
first it may take a while but you need to learn the differernce between variable types. Next DONOT use "simple variable names" microsoft has taken them and you will get confused between your listbox variable and the listbox Control (an object). third in this case control source and listbox source are different (look in VBA help) You can assign a cell refernce to a control but a list box is a special control that allows you to assign a range. your selection of entire row puts250 items into the list box (many blank?) be more specific with the columns you need for the listbox selections Sooo play with this and post back: dim mylistboxsource as range set mylistboxsource =Thisworkbook.Sheets("data 3").range(bespecific) ' SP: "set" required for objects ..rowsource = mylistboxsource msgbox mylistboxsource.address ' use message boxes durring coding to show what the PC thinks you said "Scott J" wrote: Here it is: dim listbox As Long listbox = Sheets Data("data 3").range("an4:an500").end(xlUp).row with worksheets("Item Tracker").listbox1 .ControlSource = Worksheet("data 3").range("listbox").address(external:=True) End With I am relatively new to coding so try not to be to brutal on me. Thanks, Scott J "Vacation's Over" wrote: post your rowsource attempt code "Scott J" wrote: Hi everyone, I have a listbox on a userform, that I created from the control toolbox, that appears when a user changes the selection on a combo box. I can get the form to appear with the listbox when the combobox is changed, but I can't get the list box to populate with the info. The data that populates the list box is named with a dynamic range. If I put the listbox directly onto the worksheet, I can get it to fill with the listrangefill property with code I wrote, but when I put it onto the userform I can't get it to fill. I tried changing the code to the rowsorce property but that didn't work for me. Can someone provide the code I need to have the listbox fill when the user form is opened? Thanks, Scott |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listbox
Thanks for the help.....I will play with this and let you know how it turns
out. "Vacation's Over" wrote: OK first it may take a while but you need to learn the differernce between variable types. Next DONOT use "simple variable names" microsoft has taken them and you will get confused between your listbox variable and the listbox Control (an object). third in this case control source and listbox source are different (look in VBA help) You can assign a cell refernce to a control but a list box is a special control that allows you to assign a range. your selection of entire row puts250 items into the list box (many blank?) be more specific with the columns you need for the listbox selections Sooo play with this and post back: dim mylistboxsource as range set mylistboxsource =Thisworkbook.Sheets("data 3").range(bespecific) ' SP: "set" required for objects .rowsource = mylistboxsource msgbox mylistboxsource.address ' use message boxes durring coding to show what the PC thinks you said "Scott J" wrote: Here it is: dim listbox As Long listbox = Sheets Data("data 3").range("an4:an500").end(xlUp).row with worksheets("Item Tracker").listbox1 .ControlSource = Worksheet("data 3").range("listbox").address(external:=True) End With I am relatively new to coding so try not to be to brutal on me. Thanks, Scott J "Vacation's Over" wrote: post your rowsource attempt code "Scott J" wrote: Hi everyone, I have a listbox on a userform, that I created from the control toolbox, that appears when a user changes the selection on a combo box. I can get the form to appear with the listbox when the combobox is changed, but I can't get the list box to populate with the info. The data that populates the list box is named with a dynamic range. If I put the listbox directly onto the worksheet, I can get it to fill with the listrangefill property with code I wrote, but when I put it onto the userform I can't get it to fill. I tried changing the code to the rowsorce property but that didn't work for me. Can someone provide the code I need to have the listbox fill when the user form is opened? Thanks, Scott |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
listbox B conditional of input in Listbox A | Excel Discussion (Misc queries) | |||
VBA: Creating listbox similar to the one in Pivot table (Listbox+Checkbox) | Excel Programming | |||
Multicolumn Listbox and ordinary listbox | Excel Programming | |||
listbox.value not equal to listbox.list(listbox.listindex,0) | Excel Programming | |||
Is refreshing listbox rowsource in listbox click event possible? | Excel Programming |