LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Transferring from both columns of a listbox to another

I have two two-column listboxes in a userform. I want to pass selected
elements of the first listbox to the other, but I can't seem to figure
out how to get both columns to pass.

The first column is a CAS registry number and the second column is the
Chemical Name. I want to be able to (multi)select these from the first
listbox (populated by a worksheet range referenced by the RowSource
property), run my code, and have these selected elements show up in
the second listbox exactly as in the first. Instead, I only get the
first column (the CAS registry number).

Here's my code:

================

Private Sub CmdAddCAS_Click()
Dim i As Integer
Dim j As Integer
Dim k As Integer

'Make sure something is selected
If LBoxCAS.ListIndex = -1 Then Exit Sub

'Make sure no duplicates
For j = 0 To LBoxCASSelected.ListCount - 1
For i = 0 To LBoxCAS.ListCount - 1
If LBoxCAS.Selected(i) Then
If LBoxCAS.List(i) = LBoxCASSelected.List(j) Then
Beep
Exit Sub
End If
End If
Next i
Next j

'Make transfer
For k = 0 To LBoxCAS.ListCount - 1
If LBoxCAS.Selected(k) Then
LBoxCASSelected.AddItem LBoxCAS.List(k)
End If
Next k
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
listbox B conditional of input in Listbox A Kim K Excel Discussion (Misc queries) 1 October 31st 06 08:27 PM
Listbox B if LIstbox A equals Kim K Excel Discussion (Misc queries) 2 October 31st 06 07:03 PM
transferring formats jonas.ornborg Excel Worksheet Functions 7 May 23rd 06 01:35 PM
transferring files DAZED AND CONFUSED Excel Worksheet Functions 2 September 24th 05 04:33 PM
multiple columns / rows to be referenced through a listbox Hru48 Excel Discussion (Misc queries) 0 July 4th 05 04:12 PM


All times are GMT +1. The time now is 01:20 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"