Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with Listbox Columnwidths property

Status
Not open for further replies.

Porsche996GT2

Programmer
Oct 13, 2004
41
US
Hello all,

I'm trying to get the listbox columnwidths property to work though the syntax that MS Excel VBA Help provides does not work. Here's part of the code:

Private Sub BO_Selection_Form_Initialize()

With Me
With .BO_Listbox
.ColumnCount = 3
.ColumnWidths 36;20;200
.RowSource = BO_Select_Range
End With
End With

End Sub

Also, how do you incorporate a horizontal scrollbar in this situation?

TIA!
 
Hi Porsche996GT2,

Try assigning it as a string value ..

[blue][tt] .ColumnWidths[/tt][red][tt] = "[/tt][/red][tt]36,20,200[/tt][red][tt]"[/tt][/red][/blue]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
Thanks for your reply, Tony. I tried it but it doesn't seem to work...
 
Assuming "BO_Select_Range" is the name of a range in your worksheet, then this should do the trick:
Code:
Private Sub UserForm_Initialize()
  With Me
    With .BO_ListBox
        .ColumnCount = 3
        .ColumnWidths = "36;20;200"
        .RowSource = "BO_Select_Range"
    End With
  End With
End Sub
 
Hi Porsche996GT2,

Sorry. Looking at your post, it seems you must have the comma as the decimal separator and so must use the semicolon to separate the column width values. Try, instead, ..

[blue][tt] .ColumnWidths = "36[/tt][red][tt];[/tt][/red][tt]20[/tt][red][tt];[/tt][/red][tt]200"[/tt][/blue]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top