Textbox focus change to next text box when enter pressed

jason231774

New Member
Joined
Jul 11, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi,
I am making a dashboard having multiple text-box's on dashboard (not user-form). I have set multiple codes to format and to fill values in cells in other sheet. I want my cursor to move to next text box when enter is pressed to fill value in another text-box

the name of 1st text box is SA and 2nd text box name is DP
code i am using to fill values and format is :-

Private sub SA_lostfocus
ActiveSheet.SA.value = format(ActiveSheet.SA.value, "$##,###.00")
worksheets("sheet2").range("B2").value = ActiveSheet.SA
End sub

so after filling value in SA text box I want to move to next text-box DP with enter key so i don't have to use mouse to fill value in DP text box
see the attached pic for reference

If anyone could help me with the code, it will be really helpful

Also, I fave tried to set focus at key-code 13 with keydown but it shows error saying object doesn't support this property
 

Attachments

  • Screenshot 2022-07-11 at 9.04.19 PM.png
    Screenshot 2022-07-11 at 9.04.19 PM.png
    27.3 KB · Views: 33

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi and welcome to MrExcel!

Try this:

VBA Code:
Private Sub SA_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
  If KeyCode = 13 Then
    DP.Activate
  End If
End Sub
 
Upvote 0
It worked.... Thanks a ton. I have been trying so hard to make it work and finally it worked with your support. Thank you once again
This platform is really one of best to learn with practical situations.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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