Multicolum listbox will not adjust column widt in excel 2003

espenskeie

Well-known Member
Joined
Mar 30, 2009
Messages
632
Hello

I have a userform with a multicolumn listbox that keeps 8 columns. In 2010 excel I get everything nice and perfect, but when I run the code in 2003 my columns are all messed up. I thought that this code would do the job, but obviuos it wont:

Code:
Dim rng As Range
Dim iX As Integer, iY As Integer
Dim CW As String


With Sheets("1HourDATA")
'get the range for the RowSource
For iX = 1 To 4
Set rng = Choose(iX, .Range("LongList"), .Range("ShortList"), .Range("TickList"), .Range("Ticklist"))
With Me("ListBox" & iX + 2)
.ColumnCount = rng.Columns.count
.RowSource = rng.Address(external:=True)
CW = ""
'match ColumnWidths to RowSouce Columns
For iY = 1 To .ColumnCount
CW = CW & rng.Columns(iY).Width & ";"
Next iY
.ColumnWidths = CW
.ListIndex = 0
End With
Next iX
End With

This is the only thing missing before I can finish the project...

Kind regards
Espen
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Watch MrExcel Video

Forum statistics

Threads
1,130,447
Messages
5,642,209
Members
417,262
Latest member
andrewd1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top