LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default 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




.



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to create multiple listboxes in same collumn? Ken C[_2_] Excel Discussion (Misc queries) 0 September 25th 09 07:50 PM
Userform with 2 Listboxes Mike R. Excel Programming 2 February 12th 05 07:21 AM
Userform w/ Multiple listboxes that link miker1999[_13_] Excel Programming 1 April 27th 04 03:22 AM
Userform w/ Multiple listboxes that link miker1999[_12_] Excel Programming 0 April 20th 04 12:35 PM
Userform and reading multiple listboxes Bijl167[_6_] Excel Programming 3 December 8th 03 01:40 PM


All times are GMT +1. The time now is 10:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"