ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
Hi,
Is there a simple way to populate a seconds ListBox.
I currently use a code which populates my first ListBox BUT i also at the same time wish to have it populate ListBox2
This is the code in use so far BUT is there something simple like ListBox2.Value = ListBoxSearch.Value ??
Basically if ZZZ is populated into the first ListBox then ZZZ also needs to populate the seconds ListBox
Is there a simple way to populate a seconds ListBox.
I currently use a code which populates my first ListBox BUT i also at the same time wish to have it populate ListBox2
This is the code in use so far BUT is there something simple like ListBox2.Value = ListBoxSearch.Value ??
Basically if ZZZ is populated into the first ListBox then ZZZ also needs to populate the seconds ListBox
Rich (BB code):
Private Sub TextBoxSearchColumnC_Change()
Dim R As Range, f As Range, cell As String, added As Boolean
Dim sh As Worksheet
Set sh = Sheets("POSTAGE")
sh.Select
With ListBoxSearch
.Clear
.ColumnCount = 2
.ColumnWidths = "100;0"
If TextBoxSearchColumnC.Value = "" Then Exit Sub
Set R = Range("C9", Range("C" & Rows.Count).End(xlUp))
Set f = R.Find(TextBoxSearchColumnC.Value, LookIn:=xlValues, LookAt:=xlPart)
If Not f Is Nothing Then
cell = f.Address
Do
added = False
For i = 0 To .ListCount - 1
Select Case StrComp(.List(i), f.Value, vbTextCompare)
Case 0, 1
.AddItem f.Value, i
.List(i, 1) = f.Row
added = True
Exit For
End Select
Next
If added = False Then
.AddItem f.Value
.List(.ListCount - 1, 1) = f.Row
End If
Set f = R.FindNext(f)
Loop While Not f Is Nothing And f.Address <> cell
TextBoxSearchColumnC = UCase(TextBoxSearchColumnC)
.TopIndex = 0
Else
MsgBox "NO ITEM WAS FOUND USING THAT INFORMATION", vbCritical, "POSTAGE SHEET ITEM SEARCH"
TextBoxSearchColumnC.Value = ""
TextBoxSearchColumnC.SetFocus
End If
End With
End Sub