Combobox default

Ziggy12

Active Member
Joined
Jun 26, 2002
Messages
365
I've got five items in my combobox. How do I get it to display the fifth item on initialisation?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
I presume you are using the form control combo box?

You could do it using the Active ComboBox, and after adding your list, set the combo box value to your 5th item.

D
 
Upvote 0
Something like this in the form's Initialize event.
Code:
ComboboBox1.ListIndex = ComboBox1.ListCount-1
 
Upvote 0
Almost
There are 5 items in the combobox - each is a month loaded from a named range. I want the combobox to select the last entry as a default.

I suspect seltext is the way to go but can't get it to sel the last item. Something like
combobox5.seltext combobox5.listcount+1.text

ziggy
 
Upvote 0
What do you mean by 'select'?

The code I posted will definitely set the value in the combobox to the last item in the list.

If you want to have it highlighted/selected try this, though I'm not sure why you would want to.:)
Code:
    ComboBox1.ListIndex = ComboBox1.ListCount - 1
    ComboBox1.SelStart = 0
    ComboBox1.SelLength = Len(ComboBox1.Value)
 
Upvote 0
Your first post did work. I didn't change the second instance of combobox1 to 5 in my code.
The text gets selected as well.
thanks for your help.

cheers
ziggy
 
Upvote 0

Forum statistics

Threads
1,214,424
Messages
6,119,407
Members
448,894
Latest member
spenstar

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