Combobox doesn't recognise enter key value

fugifox

Registered User.
Local time
Today, 01:02
Joined
Oct 31, 2006
Messages
95
I've created a combo box in Excel but I figure out that it's not as powerful as the one in Access.
Anyway my main problem is that I am trying to track the Enter key
so since the ascii code of that key is 13 I've added the following event

Private Sub ComboBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 13 Then
MsgBox "Entered Pressed!"
End If

End Sub

but I figure out (through debugging) that the Enter Key doesn't trigger
then KeyPress event.

Since I am not very familiar with Excel events I would like your help.

Thanks in advance
 
Had a look and from what I can see the enter key doesn't perform any actions in an excel combobox and therefore doesn't trigger the event, so there isn't much point in capturing the enter keypress, even if you could, as it performs no actions.
 
I was afraid of that.
So what are your suggestions?
 
Might help if you explain what you are actually trying to do.
 
Ok, I was asked to design a kind of list having the following features:

List will consist of (at least at the beginning) a single column with the
cell of the first row to be used for data entry (that's why the Enter key).
User will type the desired data and press the Enter key
1) If the entered data do not belong to the list, it will be added to the last empty row of the list (column)
2 if the entered data does belong to the list it will be copied somewhere.

I believe that I can implement all these except the data entry.
That's why I need your help
 
If the data is being entered into a cell you want to use workbook events. So it would be something like:

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

If Sh.Name = "name" And _
   Target.Address = "A1" Then
   
   do stuff
   application.enableevents = false
   thisworkbook.worksheets.range("A1").value = ""
   application.enableevents = true
end if

End Sub
 

Users who are viewing this thread

Back
Top Bottom