Populate second ListBox from first Listbox values

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,237
Office Version
  1. 2007
Platform
  1. 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

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
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
There is this.

Me.ListBox2.List = Me.ListBoxSearch.List
 
Upvote 0
Solution
It does depend on when you want the list in ListBoxSearch.List to be populated or updated.
 
Upvote 0

Forum statistics

Threads
1,215,603
Messages
6,125,782
Members
449,259
Latest member
rehanahmadawan

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