Setting Column Widths of a ListBox
I am using the code below to set the width of columns in a ListBox on a UserForm in Excel. However, I get the error "Could not set the ColumnWidths property. Type mismatch". Any thoughts?
Code:
Private Sub UserForm_Initialize()
ThisWorkbook.Sheets("Sheet1").Activate
colCnt = 2
Set rng = ActiveSheet.UsedRange 'Range("A3:B25")
With ListBox1
.ColumnCount = colCnt
.RowSource = rng.Address
cw = ""
For c = 1 To .ColumnCount
cw = cw & rng.Columns(c).Width & ":"
Next c
.ColumnWidths = cw
.ListIndex = 0
End With
End Sub