Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default ComboBox.ListWidth question

Hello,
I have a form with several comboboxes. However, if the text from the
RowSource is longer than the combobox itself, I'd like the _list_ to
become wider (not the combobox), so that the longest entry in my
RowSource Range fits in.

However, the Property Inspector only lets me use " x pt" values under
ListWidth, but I don't want to provide a fixed width for my boxes.

Does anyone know how this can be done?

Thanks,Joepy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 179
Default ComboBox.ListWidth question

Joepy

You could use a sub like this in the drop button click event to resize based
on the list

Private Sub ComboBox1_DropButtonClick()
Dim Rng As Range
Dim cell As Range
Dim MaxLen As Long

Set Rng = Me.Range(Me.ComboBox1.ListFillRange)

For Each cell In Rng.Cells
MaxLen = Application.Max(Len(cell.Text), MaxLen)
Next cell

Me.ComboBox1.ListWidth = Application.Max(MaxLen * 5, 30)
End Sub

This example is from a combobox on a sheet, so if you are using a userform,
you may need to modify it slightly.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Joepy" wrote in message
om...
Hello,
I have a form with several comboboxes. However, if the text from the
RowSource is longer than the combobox itself, I'd like the _list_ to
become wider (not the combobox), so that the longest entry in my
RowSource Range fits in.

However, the Property Inspector only lets me use " x pt" values under
ListWidth, but I don't want to provide a fixed width for my boxes.

Does anyone know how this can be done?

Thanks,Joepy



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ComboBox Question jlclyde Excel Discussion (Misc queries) 2 August 27th 09 09:31 PM
another combobox question teepee Excel Discussion (Misc queries) 2 May 13th 07 01:01 AM
ComboBox Question Duncan Edment Excel Worksheet Functions 1 August 1st 06 12:42 PM
combobox Question Greg B Excel Discussion (Misc queries) 2 September 2nd 05 04:22 PM
VBA Form ComboBox question WTG Excel Worksheet Functions 3 February 26th 05 04:27 PM


All times are GMT +1. The time now is 08:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"