How to mark an item selected in the Excel VBA Form?

D

divya

I made a combobox in a VBA form and I want the user to select only
items from the list but the problem is the default selected item it
shows blank and allows user to add his input into it.
Kindly suggest a solution .I think If I give a default selected value
then the problem will be solved , but how to give the default value?

Regards
Divya
 
P

Peter T

Hi Divya,

try this with just a combobox on the form

Private Sub UserForm_Initialize()
ComboBox1.List = Array("first", "second", "third")
ComboBox1.ListIndex = 1 ' ie 1 is 2nd item
End Sub

See ListIndex in help

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top