DB73
Board Regular
- Joined
- Jun 7, 2022
- Messages
- 107
- Office Version
- 365
- 2021
- 2019
- 2016
- 2010
- 2007
- Platform
- Windows
- Mobile
- Web
Hi Peeps,
New question
got an userform with 2 listboxes
listbox1
listbox2
i want to populate the 2 listboxes from the same table but in listbox1 with column ABC
and in listbox2 column XYZ
now, already got it working for listbox1, but i aint gettin data in listbox2
as u see i did it with columnwidth.
but , as i think about this issue....do i just copy the listbox items from 1 to 2 and set the columnwidth or is it like populate listbox2 as a new one....so many questions
after , as i got this working, i'll add some comboxes to filter the data in the listboxes at once....next project
this is my code for listbox1;
New question
got an userform with 2 listboxes
listbox1
listbox2
i want to populate the 2 listboxes from the same table but in listbox1 with column ABC
and in listbox2 column XYZ
now, already got it working for listbox1, but i aint gettin data in listbox2
as u see i did it with columnwidth.
but , as i think about this issue....do i just copy the listbox items from 1 to 2 and set the columnwidth or is it like populate listbox2 as a new one....so many questions
after , as i got this working, i'll add some comboxes to filter the data in the listboxes at once....next project
this is my code for listbox1;
VBA Code:
Option Explicit
Dim ws As Worksheet, wsTemp As Worksheet
Dim lRow As Long
Private Sub UserForm_Initialize()
Set ws = ThisWorkbook.Sheets("Dump stats")
Set wsTemp = ThisWorkbook.Sheets("Temp")
PopulateListBox1
With ListBox1
.ColumnHeads = True
.ColumnCount = 56
.ColumnWidths = "0;45;0;0;0;0;0;62;50;0;0;60;0;170;80;0;0;100;0;0;0;0;0;65;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;110;90;110"
.RowSource = "dumpstats"
End With
End Sub
Private Sub commandbutton1_Click()
wsTemp.Cells.Clear
Factuur4Weken.Hide
End Sub
Private Sub PopulateListBox1()
wsTemp.Cells.Clear
Dim rng As Range
With ws
.AutoFilterMode = False
lRow = .Range("A" & .Rows.Count).End(xlUp).Row
If lRow = 1 Then
Set rng = .Range("A2:BD2")
Else
Set rng = .Range("A2:BD" & lRow)
End If
.Rows(1).Copy wsTemp.Rows(1)
rng.Copy wsTemp.Range("A2")
Application.CutCopyMode = False
wsTemp.ListObjects.Add(xlSrcRange, wsTemp.Range("A1:BD" & lRow), , xlYes).Name = "dumpstats"
End With
End Sub
Last edited: