Hi all,
I have Listbox1 which shows the values in columns D to I. The info in column J I want to show in another Listbox (the reason being is a design one as the length of string is quite long).
I am trying to ‘connect’ the two list-boxes together so that when Listbox1 is scolled up/down then Listbox2 follows suit. I have tried using the Initialize event to call a Vlookup but I can’t seem to get it to work. Any ideas?
Sub UserForm_Initialize()
With ListBox1
.ColumnCount = Range("D2:J50").Columns.Count
.List = Range("D2:J50").Value
End With
With ListBox2
If ListBox1.ListIndex = 0 Then
ListBox2.Value = Application.VLookup(Me.ListBox1, Sheets("Addresses").Range("D:J"), 7, False)
End If
End With
This is my working Listbox1 code:
Private bSkipEvents As Boolean
Sub ListBox1_Click()
If bSkipEvents Then Exit Sub
If ListBox1.ListIndex <> -1 Then
With ListBox1
TextBox16.Value = .List(.ListIndex, 0)
TextBox17.Value = .List(.ListIndex, 1)
TextBox18.Value = .List(.ListIndex, 2)
TextBox19.Value = .List(.ListIndex, 3)
TextBox20.Value = .List(.ListIndex, 4)
TextBox21.Value = .List(.ListIndex, 5)
TextBox22.Value = .List(.ListIndex, 6)
End With
End If
End Sub
Bookmarks