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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box Behavior on USER Form - Want to prevent Keying in Combo Box, Only Allowing List Selection

Status
Not open for further replies.

Randy11

Technical User
Oct 4, 2002
175
CA
Have set up a User form in Excel 2007. In this form have added a Combo box for user to be able to select info from a drop down list in the Combo box. How can I prevent manual keying into this combo box.
2 option ideas:
1) If user attempt to key into the box engage MsgBox("Must Select from List") & then clear entered info in box before allow next user action.
2) Simply not allow any entry into this box, so user either has to select from the list or hit cancel or enter to close the user form with no action taken.

Is there a property for the combo box that can accomplished this or does this need to be done with VBA? Your ideas appreciated..... R

Current Combo Box Code:
Private Sub ComboBox1_Change()
Dim varUF01 As Variant

varUF01 = UserForm1.ComboBox1.Value
Sheets("Seamless").Select

Dim iRow As Integer, iCol As Integer
For iCol = 2 To 2
For iRow = 6 To 456
If Cells(iRow, iCol).Value = "" Then
Cells(iRow, iCol).Select
ActiveCell.Value = varUF01

Call CommandButton1_Click ' (Code is Unload Me)

Exit Sub
End If
Next
Next
MsgBox "FULL"

End Sub
 
Hi,

A ComboBox is defined as a drop down WITH a TextBox.

Maybe you want a LisyBox.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Thank you Skip, will perform some testing. Sometimes the obvious eludes us...
Make it a Great Day! R
 

Did you try to set your Combo box's Style property to 2 - fmStyleDropDownList ?

Have fun.

---- Andy
 
Thanks Andy the Style Property works. Cheers
 

Just make sure your:[tt]
Private Sub ComboBox1_Change()[/tt]
fires when you need it.

If you set it as DropDownList, there is no change in a text so it will not fire (at least that's the case in VB 6)

Have fun.

---- Andy
 
In addition to setting the style, you can set MatchEntry property to 2 - fmMatchEntryNone. This will stop jumping active combobox selection when the user press a key.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top