gmaxey
02-08-2014, 12:39 PM
I have a listbox on a userform that has a variable number of columns typically over 30. I only want to display the first 3.
Is there a syntax that I can use to simplify setting the .ColumnWidths property?
0;60;150;????
Literally:
Set column 0 width = 0; Column 1 width = 60; Column 2 width = 150; and all others = 0
I'm currently doing it with code as follows:
For lngCount = 0 To ListBox1.ColumnCount - 1
Select Case lngCount
Case 0
strColWidth = "0;"
Case 1
strColWidth = strColWidth & "60;"
Case 2
strColWidth = strColWidth & "150;"
Case Else
strColWidth = strColWidth & "0;"
End Select
Next lngCount
With ListBox1
.ListIndex = -1
.ColumnWidths = strColWidth
End With
Is there a syntax that I can use to simplify setting the .ColumnWidths property?
0;60;150;????
Literally:
Set column 0 width = 0; Column 1 width = 60; Column 2 width = 150; and all others = 0
I'm currently doing it with code as follows:
For lngCount = 0 To ListBox1.ColumnCount - 1
Select Case lngCount
Case 0
strColWidth = "0;"
Case 1
strColWidth = strColWidth & "60;"
Case 2
strColWidth = strColWidth & "150;"
Case Else
strColWidth = strColWidth & "0;"
End Select
Next lngCount
With ListBox1
.ListIndex = -1
.ColumnWidths = strColWidth
End With