populate listbox with multiple column from vlookup

willsnake

New Member
Joined
Sep 9, 2014
Messages
41
good day,


I am seeking expert help as stated in the title


I have a code but it can only populate single column, I have been searching the net but can't find answer.


Hope you could help me...

Thank you...

HTML:
Private Sub fPRNumber_AfterUpdate()
Dim ws As Worksheet
Dim x, dictDim i As Long
Dim wht As Stringwht = Worksheets("PR").Range("c11").Value
ListBox1.Value = ""
ListBox1.ColumnCount = 3
ListBox1.ColumnWidths = "60;40;20;20"
Set ws = Sheets("PRData")
x = ws.Range("A1").CurrentRegion.Value
Set dict = CreateObject("Scripting.Dictionary")
For i = 2 To UBound(x, 1)
    If x(i, 2) = wht Then
        dict.Item(x(i, 6)) = ""
    End If
Next i
ListBox1.List = dict.keys

I am targeting to populate 3 columns from sheet "PRdata" from column E,F,G,H
 
Last edited:

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Maybe
Code:
For i = 2 To UBound(x, 1)
    If x(i, 2) = wht Then
        dict.Item(x(i, 6)) = Array(x(i, 5), x(i, 6), x(i, 7),x(i,8))
    End If
Next i
ListBox1.List = Application.Index(dict.Items, 0, 0)
End Sub
 
Upvote 0
Maybe
Code:
For i = 2 To UBound(x, 1)
    If x(i, 2) = wht Then
        dict.Item(x(i, 6)) = Array(x(i, 5), x(i, 6), x(i, 7),x(i,8))
    End If
Next i
ListBox1.List = Application.Index(dict.Items, 0, 0)
End Sub

Thank you very much sir... It worked!!!!
 
Upvote 0

Forum statistics

Threads
1,223,710
Messages
6,174,019
Members
452,542
Latest member
Bricklin

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