Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform with Multiple ListBoxes not working
I have a userform which has two listboxes. Listbox1 lists
all these sheets in my spreadsheet. there is an Add and Delete button which allows teh user to click on items in Listbox1 and add them to Listbox2. When I click onto 1 item in Listbox1 and then press Add, the code fails. I can't figure out why this is failing. It was working before. I am getting a: Run Time Error Type mismatch error The last line of code that says: ListBox2.AddItem ListBox1.Value Has a null value for ListBox1.Value. This usually has the name of the sheet I have selected. Another thing is that I cannot remember what cbDuplicates is. Its not a variable name. Private Sub AddButton_Click() If ListBox1.ListIndex = -1 Then Exit Sub If Not cbDuplicates Then ' See if item already exists For i = 0 To ListBox2.ListCount - 1 If ListBox1.Value = ListBox2.List(i) Then Beep Exit Sub End If Next i End If ListBox2.AddItem ListBox1.Value End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform with Multiple ListBoxes not working
I can't get the error myself, it works fine.
Maybe cbDuplicates is some Boolean variable set when the listbox item is selected? -- HTH RP (remove nothere from the email address if mailing direct) "ExcelMonkey" wrote in message ... I have a userform which has two listboxes. Listbox1 lists all these sheets in my spreadsheet. there is an Add and Delete button which allows teh user to click on items in Listbox1 and add them to Listbox2. When I click onto 1 item in Listbox1 and then press Add, the code fails. I can't figure out why this is failing. It was working before. I am getting a: Run Time Error Type mismatch error The last line of code that says: ListBox2.AddItem ListBox1.Value Has a null value for ListBox1.Value. This usually has the name of the sheet I have selected. Another thing is that I cannot remember what cbDuplicates is. Its not a variable name. Private Sub AddButton_Click() If ListBox1.ListIndex = -1 Then Exit Sub If Not cbDuplicates Then ' See if item already exists For i = 0 To ListBox2.ListCount - 1 If ListBox1.Value = ListBox2.List(i) Then Beep Exit Sub End If Next i End If ListBox2.AddItem ListBox1.Value End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform with Multiple ListBoxes not working
Its funny because I copies this from an old macro I had
without much thought as to how it worked. It was working fine at first and then it stopped. I just did a search in my code on cbDuplicates and it only comes up with 1 occurence - the one in the code snippet I posted. What role is that playing in that specific line of code? I can't seem to figure out why its there and what it is doing? -----Original Message----- I can't get the error myself, it works fine. Maybe cbDuplicates is some Boolean variable set when the listbox item is selected? -- HTH RP (remove nothere from the email address if mailing direct) "ExcelMonkey" wrote in message ... I have a userform which has two listboxes. Listbox1 lists all these sheets in my spreadsheet. there is an Add and Delete button which allows teh user to click on items in Listbox1 and add them to Listbox2. When I click onto 1 item in Listbox1 and then press Add, the code fails. I can't figure out why this is failing. It was working before. I am getting a: Run Time Error Type mismatch error The last line of code that says: ListBox2.AddItem ListBox1.Value Has a null value for ListBox1.Value. This usually has the name of the sheet I have selected. Another thing is that I cannot remember what cbDuplicates is. Its not a variable name. Private Sub AddButton_Click() If ListBox1.ListIndex = -1 Then Exit Sub If Not cbDuplicates Then ' See if item already exists For i = 0 To ListBox2.ListCount - 1 If ListBox1.Value = ListBox2.List(i) Then Beep Exit Sub End If Next i End If ListBox2.AddItem ListBox1.Value End Sub . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform with Multiple ListBoxes not working
Its funny because I copies this from an old macro I had
without much thought as to how it worked. It was working fine at first and then it stopped. I just did a search in my code on cbDuplicates and it only comes up with 1 occurence - the one in the code snippet I posted. What role is that playing in that specific line of code? I can't seem to figure out why its there and what it is doing? -----Original Message----- I can't get the error myself, it works fine. Maybe cbDuplicates is some Boolean variable set when the listbox item is selected? -- HTH RP (remove nothere from the email address if mailing direct) "ExcelMonkey" wrote in message ... I have a userform which has two listboxes. Listbox1 lists all these sheets in my spreadsheet. there is an Add and Delete button which allows teh user to click on items in Listbox1 and add them to Listbox2. When I click onto 1 item in Listbox1 and then press Add, the code fails. I can't figure out why this is failing. It was working before. I am getting a: Run Time Error Type mismatch error The last line of code that says: ListBox2.AddItem ListBox1.Value Has a null value for ListBox1.Value. This usually has the name of the sheet I have selected. Another thing is that I cannot remember what cbDuplicates is. Its not a variable name. Private Sub AddButton_Click() If ListBox1.ListIndex = -1 Then Exit Sub If Not cbDuplicates Then ' See if item already exists For i = 0 To ListBox2.ListCount - 1 If ListBox1.Value = ListBox2.List(i) Then Beep Exit Sub End If Next i End If ListBox2.AddItem ListBox1.Value End Sub . |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform with Multiple ListBoxes not working
Hey it works when I change the multiselect property back
to fm MultiselectSingle. I had it on fm MultiselectMulti. Is the cbDuplicates affecting that property? What changes would I make if I in fact want the property set to fm MultiselectMulti. Thanks -----Original Message----- I can't get the error myself, it works fine. Maybe cbDuplicates is some Boolean variable set when the listbox item is selected? -- HTH RP (remove nothere from the email address if mailing direct) "ExcelMonkey" wrote in message ... I have a userform which has two listboxes. Listbox1 lists all these sheets in my spreadsheet. there is an Add and Delete button which allows teh user to click on items in Listbox1 and add them to Listbox2. When I click onto 1 item in Listbox1 and then press Add, the code fails. I can't figure out why this is failing. It was working before. I am getting a: Run Time Error Type mismatch error The last line of code that says: ListBox2.AddItem ListBox1.Value Has a null value for ListBox1.Value. This usually has the name of the sheet I have selected. Another thing is that I cannot remember what cbDuplicates is. Its not a variable name. Private Sub AddButton_Click() If ListBox1.ListIndex = -1 Then Exit Sub If Not cbDuplicates Then ' See if item already exists For i = 0 To ListBox2.ListCount - 1 If ListBox1.Value = ListBox2.List(i) Then Beep Exit Sub End If Next i End If ListBox2.AddItem ListBox1.Value End Sub . |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform with Multiple ListBoxes not working
It won't have any effect if it is not being set anywhere else, as the
variable will be empty, so it will pass that test. I commented it out, no difference. -- HTH RP (remove nothere from the email address if mailing direct) "ExcelMonkey" wrote in message ... Its funny because I copies this from an old macro I had without much thought as to how it worked. It was working fine at first and then it stopped. I just did a search in my code on cbDuplicates and it only comes up with 1 occurence - the one in the code snippet I posted. What role is that playing in that specific line of code? I can't seem to figure out why its there and what it is doing? -----Original Message----- I can't get the error myself, it works fine. Maybe cbDuplicates is some Boolean variable set when the listbox item is selected? -- HTH RP (remove nothere from the email address if mailing direct) "ExcelMonkey" wrote in message ... I have a userform which has two listboxes. Listbox1 lists all these sheets in my spreadsheet. there is an Add and Delete button which allows teh user to click on items in Listbox1 and add them to Listbox2. When I click onto 1 item in Listbox1 and then press Add, the code fails. I can't figure out why this is failing. It was working before. I am getting a: Run Time Error Type mismatch error The last line of code that says: ListBox2.AddItem ListBox1.Value Has a null value for ListBox1.Value. This usually has the name of the sheet I have selected. Another thing is that I cannot remember what cbDuplicates is. Its not a variable name. Private Sub AddButton_Click() If ListBox1.ListIndex = -1 Then Exit Sub If Not cbDuplicates Then ' See if item already exists For i = 0 To ListBox2.ListCount - 1 If ListBox1.Value = ListBox2.List(i) Then Beep Exit Sub End If Next i End If ListBox2.AddItem ListBox1.Value End Sub . |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform with Multiple ListBoxes not working
You'll use the Select property of each listbox1 item. In XL03 the help
example for the Select property does almost exactly what you want. Here's the critical bit: For i = 0 To 9 If ListBox1.Selected(i) = True Then ListBox2.AddItem ListBox1.List(i) End If Next i hth, Doug Glancy "ExcelMonkey" wrote in message ... Hey it works when I change the multiselect property back to fm MultiselectSingle. I had it on fm MultiselectMulti. Is the cbDuplicates affecting that property? What changes would I make if I in fact want the property set to fm MultiselectMulti. Thanks -----Original Message----- I can't get the error myself, it works fine. Maybe cbDuplicates is some Boolean variable set when the listbox item is selected? -- HTH RP (remove nothere from the email address if mailing direct) "ExcelMonkey" wrote in message ... I have a userform which has two listboxes. Listbox1 lists all these sheets in my spreadsheet. there is an Add and Delete button which allows teh user to click on items in Listbox1 and add them to Listbox2. When I click onto 1 item in Listbox1 and then press Add, the code fails. I can't figure out why this is failing. It was working before. I am getting a: Run Time Error Type mismatch error The last line of code that says: ListBox2.AddItem ListBox1.Value Has a null value for ListBox1.Value. This usually has the name of the sheet I have selected. Another thing is that I cannot remember what cbDuplicates is. Its not a variable name. Private Sub AddButton_Click() If ListBox1.ListIndex = -1 Then Exit Sub If Not cbDuplicates Then ' See if item already exists For i = 0 To ListBox2.ListCount - 1 If ListBox1.Value = ListBox2.List(i) Then Beep Exit Sub End If Next i End If ListBox2.AddItem ListBox1.Value End Sub . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Is there a way to create multiple listboxes in same collumn? | Excel Discussion (Misc queries) | |||
Userform with 2 Listboxes | Excel Programming | |||
Userform w/ Multiple listboxes that link | Excel Programming | |||
Userform w/ Multiple listboxes that link | Excel Programming | |||
Userform and reading multiple listboxes | Excel Programming |