2 fold question about listboxes.....

VTTW

New Member
Joined
Mar 24, 2002
Messages
26
I have two listboxes (lbavail & lbadd) with a command button (cmdadd) that adds the lbavail selection to lbadd. Works great, but....

both listboxes are formated for 3 columns with headers. lbavail displays the three columns (bn, bo & bp) as it should, but lbadd doesn't, it only shows column bn. Is there a way to code (or change the existing code) so the lbadd displays the three columns of info??

Code:
~~~~~~~~~~~~~~
Private Sub cmdremove()
Dim i As Integer
Application.ScreenUpdating = False
With Me.lbaddItems
For i = .ListCount - 1 To 0 Step -1
If .Selected(i) = True Then
.RemoveItem (i)
End If
Next i
End With
SortListBoxes
Application.ScreenUpdating = True

End Sub
~~~~~~~~~~~~~~~~~~~~~~
Private Sub cmdadd()
Dim i As Integer
Application.ScreenUpdating = False
With Me.lbAvail
For i = .ListCount - 1 To 0 Step -1
If .Selected(i) Then
Me.lbadd.AddItem .List(i)
End If
Next i
End With
SortListBoxes
Application.ScreenUpdating = True
End Sub
~~~~~~~~~~~~
Private Sub cmdcancel_Click()
Unload Me
End Sub
~~~~~~~~~~~~~~
Private Sub SortBoxes()
Dim ListContent() As Variant, i As Integer, li As Integer
Application.ScreenUpdating = False
Erase ListContent
With Me.lbAvail
If .ListCount > 1 Then
li = .ListIndex
ReDim ListContent(1 To .ListCount)
For i = 0 To .ListCount - 1
ListContent(i + 1) = .List(i)
Next i
For i = LBound(ListContent) To UBound(ListContent)
Next i
.ListIndex = li
End If
End With
Erase ListContent
With Me.lbadd
If .ListCount > 1 Then
li = .ListIndex
ReDim ListContent(1 To .ListCount)
For i = 0 To .ListCount - 1
ListContent(i + 1) = .List(i)
Next i
.Clear
For i = LBound(ListContent) To UBound(ListContent)
.AddItem ListContent(i)
Next i
.ListIndex = li
End If
End With
Application.ScreenUpdating = True
Me.Repaint
End Sub
~~~~~~~~~~~~~~~~~
Private Sub CommandButton5_Click()
lbadd.Clear
End Sub
~~~~~~~~~~~
Private Sub dwgledgerCommandButton_Click()
dwgledger.Show
End Sub
~~~~~~~~~~~~~~
Private Sub lbAvail_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
btnSelect1_Click
End Sub
~~~~~~~~~~~~
Private Sub lbadd_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
btnDeSelect1_Click
End Sub
~~~~~~~~~~~~~
Private Sub saveexitbutton_Click()
Unload Me
End Sub
~~~~~~~~~~~~
Private Sub UserForm_Activate()
Me.trnjobname = Main.txtboxjobname
Me.trnjobnumber = Main.MAINjobnumberlist

Range("bn3:br3000").Sort Key1:=Range("bn3"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

lbAvail.RowSource = "bn3:bq300"

sentforlist.Value = Range("cf3")
sentforlist.RowSource = "cf3:cf6"
sentvialist.Value = Range("cg3")
sentvialist.RowSource = "cg3:cg9"
End Sub
~~~~~~~~~~~~~~

Thanks,
Mark
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,144,741
Messages
5,726,017
Members
422,653
Latest member
mntsiki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top