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
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