PDA

View Full Version : SetFocus on worksheet


bcass
08-23-03, 11:40
I have 2 textboxes on a worksheet - txtInput1 and txtInput2. When txtInput1 has the focus, and the user presses TAB, I want the focus to shift to txtInput2. Here is the code I'm using:

Private Sub txtInput1_KeyPress(ByVal KeyAscii As _
MSForms.ReturnInteger)
If KeyAscii = 9 Then txtInput2.SetFocus
End Sub

However, this doesn't work. I also tried .Select rather than .SetFocus, but that just selects the textbox frame as an object, rather than placing the cursor into txtInput2.

Any help much appreciated.