Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
HI.
I have two ListBox(ListBox1&ListBox2) in Worksheet1. The amount of items of ListBox2 depends on the choice of items in ListBox1. On Worksheet2, I build a Private Sub ListBox1_Click() On Error Resume Next With ListBox2 .ListFillRange = Range("DetailInfoAddress").Value End With End Sub I mapped the cells relationship between ListBOX1 and ListBOX2 through the property"LinkedCell". The DetailInfoAddress is the name for one cell in worksheet2. It stands for a range info like:Worksheet2!$B$15:$B$17. However,this VBA program couldn't display the Items in the ListBox2. Could you Fix this program for me?Thank you in advance!!! Regards Sam |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I think your problem lies in that you are using a list box from the
forms toolbar and not a list box from the control toolbox. You have much greater control over listboxes created through the control toolbox. Also where do you want the list items displayed? In a pop-up, certain cells, the immediate window? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
HI,
I used listbox from the control toolbox. And I want the list of item displayed in the certain cells of listbox2. In my opinion, I think the property ".listFillRange" of ListBox2 can load the info from the "DetailInfoAddress". However, it doesn't work. Do you have some ideas? Regards Sam |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry I misunderstood what you were trying to accomplish.
It might be easier to loop through each cell in the named range one at a time as opposed to assigning the whole range as the source? For each cell in sheet2.Range("DetailInfoAddress") With ListBox2 .additem cell.Value End With Next cell |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi.
I tried this code. But it doesn't work. I pasted this code by clicking my listbox1. Private Sub ListBox1_Click() On Error Resume Next For Each cell In Sheet2.Range("DetailInfoAddress") With ListBox2 .AddItem cell.value End With Next cell End Sub In my case, "DetailInfoAddress" is the name of one cell in sheet2. Its value depends on the item choice of Listbox1. I used the linkedcell property to connect this two listbox Here is one example of "DetailInfoAddress" value, Sheet2!$B$2:$B$6. Could you help me to try this code again? Thank you! Best Regards Sam |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You were very close with your original code. The only difference is
you do not need the named range within the range property. Try these: If the listbox is directly on the worksheet: Sheet1.ListBox1.ListFillRange = "MyNamedRange" If the listbox is in a userform: Me.ListBox1.ListFillRange = "MyNamedRange" Sorry for leading you off track originally. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Always display items AND Include hidden items in totals | Excel Discussion (Misc queries) | |||
Adding Items to a ListBox-Unique Items Only | Excel Programming | |||
Items in a Listbox | Excel Programming | |||
Fill a ListBox with items using VBA | Excel Programming | |||
Sort Listbox Items | Excel Programming |