Excel crashes everytime I send focus from control to worksheet

D

Daves_Solutions

I have an embedded control in my spreadsheet and everytime that the user
presses the tab key I send the focus to the next cell adjacent to the
control. However each time that this little piece of code runs it crashes
excel.

If I put a text box in the cell and send the focus to the textbox I incur no
problems.

Any explanations or help that you can give me would be greatly appreciated.
Thanks in advance!
 
G

Greg Wilson

Assuming a combobox added from the Control Toolbox tool bar, this works fine
for me:

Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
If KeyCode = 9 Then
ComboBox1.TopLeftCell(1, 4).Select
Selection.Value = ComboBox1.Text
End If
End Sub

Regards,
Greg
 
D

Daves_Solutions

Greg Wilson said:
Assuming a combobox added from the Control Toolbox tool bar, this works fine
for me:

Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
If KeyCode = 9 Then
ComboBox1.TopLeftCell(1, 4).Select
Selection.Value = ComboBox1.Text
End If
End Sub

Regards,
Greg
Thanks, this works fine on my developing computer so I (assume) it will be
fine at work. I appreciate it.
 

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