Sharid
Well-known Member
- Joined
- Apr 22, 2007
- Messages
- 1,064
- Office Version
- 2016
- Platform
- Windows
I have a userform with a tabstrip 6 tabs and a listbox, depending on which tab you are will determine how many columns the listbox should have. This is from 2 columns to 18. I therefore have to set the code to show for each column type in the tab. I don't want to set it for the max number of columns 18 as it creates a horizontal scroll bar at the bottom and also flickers more when being populated.
Is there a way it could show the columns dynamically, depending on columns with data?
or
and so on
Is there a way it could show the columns dynamically, depending on columns with data?
VBA Code:
Userform1.ListBox1.ColumnCount = 2
Userform1.ListBox1.ColumnWidths = "350;250"
Userform1.ListBox1.RowSource = "'" & Sheet19.Name & "'!$A$1:$b$" & Sheet19.Cells(Sheet19.Rows.Count, 1).End(xlUp).Row
or
VBA Code:
Userform1.ListBox1.ColumnCount = 6
Userform1.ListBox1.ColumnWidths = "350;250;250;250;250;250"
Userform1.ListBox1.RowSource = "'" & Sheet19.Name & "'!$A$1:$F$" & Sheet19.Cells(Sheet19.Rows.Count, 1).End(xlUp).Row
and so on