JoePineapples
Beginner
Points270Trophies1Posts72
- Jul 1st 2008
- #1
Hi All
I have a userform That has Several client information textboxes on it including a textbox called txtClientID.
What I would like to do is add a multicolumn listbox to the form and populate it from a worksheet - "sheet3" Columns B to E. These records would be filtered by the txtClientID textbox [this would correspond to a client ID value in column E].
So I would have a listbox that contained all the records from Sheet 3 that relate to the Client ID on the userform.
Any help would be much appriciated.
JP
You can go anywhere you want if you look serious and carry a clipboard.
Kenneth Hobson
Super old
Likes Received17Points5,557Trophies2Posts1,846
- Jul 1st 2008
- #2
Re: Populate Multicolumn Listbox
The .List property is one way.
Code
- Private Sub txtClientId_Change[]
- FillLBGreaterThan txtClientId.Value, Me.ListBox1
- End Sub
- Private Sub UserForm_Initialize[]
- txtClientId.Value = 1000
- FillLBGreaterThan txtClientId.Value, Me.ListBox1
- End Sub
- Sub FillLBGreaterThan[idValue As Double, LB As MSForms.ListBox]
- Dim r As Range, c As Range, s As String
- Set r = Sheet3.Range["B2:" & Cells[Rows.Count, "B"].Address]
- LB.Clear
- LB.ColumnCount = 4
- For Each c In r
- If c.Offset[0, 3].Value > idValue Then
- LB.AddItem c.Value
- LB.List[LB.ListCount - 1, 1] = c.Offset[0, 1]
- LB.List[LB.ListCount - 1, 2] = c.Offset[0, 2]
- LB.List[LB.ListCount - 1, 3] = c.Offset[0, 3]
- End If
- Next c
- End Sub
Files
95923 MultiColumn Listbox.zip
[14.79 kB, downloaded 569 times, last: Yesterday, 1:21am]
[SIZE="2"]
Merge Or Convert Excel | Trading Add-ins For Excel | Convert Excel Into Web Pages | Convert Databases Including Excel | Business Spreadsheets | Build Automatic Trading Models in Excel [/SIZE]>