Thread: Listbox
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Vacation's Over Vacation's Over is offline
external usenet poster
 
Posts: 279
Default 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