Hi Guys
My Brain is not working today! It must be that Friday Feeling!
I have the below code and wondered if anybody can think of a better way of doing the i = 4 or i = 5 and so on:
The Code builds a string of data to resize and hide columns in a Listbox.
My Brain is not working today! It must be that Friday Feeling!
I have the below code and wondered if anybody can think of a better way of doing the i = 4 or i = 5 and so on:
VBA Code:
Dim ColWidth As String
For i = 1 To UBound(arr, 1)
If ColWidth = "" Then
ColWidth = Orders.Columns(i).ColumnWidth + 20
ElseIf i = 4 Or i = 5 Or i = 7 Or i = 8 Or i = 9 Or i = 10 Or i = 11 _
Or i = 12 Or i = 13 Or i = 14 Or i = 15 Or i = 16 Or i = 17 Or i = 18 _
Or i = 19 Or i = 20 Or i = 21 Or i = 24 Or i = 25 Or i = 26 Or i = 27 _
Or i = 28 Or i = 29 Or i = 30 Or i = 31 Or i = 32 Or i = 33 Or i = 34 _
Or i = 35 Or i = 36 Or i = 37 Or i = 38 Or i = 39 Or i = 40 Or i = 41 _
Or i = 42 Or i = 43 Or i = 44 Or i = 46 Or i = 47 Or i = 48 Or i = 49 _
Or i = 50 Or i = 51 Or i = 52 Or i = 53 Or i = 54 Or i = 55 Or i = 56 _
Or i = 59 Or i = 60 Then
ColWidth = ColWidth & ", 0"
Else
ColWidth = ColWidth & ", " & Orders.Columns(i).ColumnWidth * 5
End If
Next
UserForm1.ListBox1.ColumnWidths = ColWidth
The Code builds a string of data to resize and hide columns in a Listbox.