Setting Column Widths of a ListBox


Posted by Stan on October 17, 2001 5:57 AM

I am using the code below to set the width of columns in a ListBox. However, I get the error "Could not set the ColumnWidths property. Type mismatch". Any thoughts?

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


Cheers

Stan



Posted by Stan on October 17, 2001 8:53 AM

Found Mistake

I typed a colon instead of a sem-colon :-)