set focus cursor again for first textbox after press Enter last textbox

Mussa

Board Regular
Joined
Jul 12, 2021
Messages
241
Office Version
  1. 2019
  2. 2010
I have textboxes (textbox71:textbox142). so what I want after filling number into textbox 142 and press enter should return cursor into textbox71 to show format number into textbox142.
I used this but doesn't work !
VBA Code:
Private Sub TextBox142_AfterUpdate()
TextBox71.SetFocus
End Sub
any idea guys?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Something like this:
VBA Code:
Private Sub TextBox142_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then
         TextBox71.SetFocus
    End If
End Sub
 
Upvote 1
Solution
thanks .

it shows error
1.PNG




I'm sure about names and numbers for textboxes .
 
Upvote 0
I think you have another keydown event at somewhere else. Just move the If condition there.
 
Upvote 0
I no know what happens !:unsure:
I did not find duplicated for this event:confused: , but now it works !(y)
thanks very much for your help;)
 
Upvote 0

Forum statistics

Threads
1,215,406
Messages
6,124,720
Members
449,184
Latest member
COrmerod

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top