Fifty columns?Originally Posted by Learner123
This is a typo, yes?
But here you only define three widths.
[vba] 'Set column widths
.ColumnWidths = "50;80;100"[/vba]
Add a dynamic range. Formula tab, Define Name. EnterAdditionally, the range ("A7:C13") will change over time as a result of rows
[vba]=OFFSET(Sheet1!$A$7,0,0,COUNTA(Sheet1!$C:$C),3)[/vba]Now, the rows will be dynamic.
Whatever name you give the range, enter that into the RowSource on the listbox.
Reduce the code will look like this.
[vba]
Private Sub UserForm2_Initialize()
Dim lbtarget As MSForms.ListBox
'Fill the listbox
Set lbtarget = Me.ListBox1
With lbtarget
'Determine number of columns
.ColumnCount = 3
'Set column widths
.ColumnWidths = "50;80;100"
End With
End Sub
[/vba]