change ColumnWidths of ListBox has error if adding cm or in on it

HunHun

New Member
Joined
May 22, 2011
Messages
4
Dear Excel Master
I tried to change the ColumnWidths some case are OK and some are not:confused:, if any Excel Master know the deep reason of how it's got error, please let me know;). Thanks!

Code:
Private Sub UserForm_Initialize()
Dim i As Long
Dim j As Long
Dim lgRow As Long
Dim asgTestData
someListBox.ColumnCount = 3
lgRow = 5
ReDim asgTestData(lgRow, someListBox.ColumnCount) As String
For j = 0 To someListBox.ColumnCount - 1
    For i = 0 To lgRow - 1
        asgTestData(i, j) = "Row " & i & ", Column " & j
    Next i
Next j
someListBox.List() = asgTestData


Private Sub TestColumnWidths_Click()
someListBox.ColumnWidths = "10;20;30" 'is OK
someListBox.ColumnWidths = "10pt;20pt;30pt" 'is OK
someListBox.ColumnWidths = "1cm;2cm;3cm" 'is error
someListBox.ColumnWidths = "1in;2in;3in" 'is error
End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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