Multicolum listbox will not adjust column widt in excel 2003

espenskeie

Well-known Member
Joined
Mar 30, 2009
Messages
636
Office Version
  1. 2016
Platform
  1. Windows
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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,214,601
Messages
6,120,460
Members
448,965
Latest member
grijken

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
Back
Top