VBA for TAB Control

oblix

Board Regular
Joined
Mar 29, 2017
Messages
183
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
  6. 2011
  7. 2010
  8. 2007
  9. 2003 or older
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
I would like to be able to have no tab control (Does not move down after pressing enter but rather remain in cell) on sheet 6 and sheet 7 only.
On all other sheets it must move down after enter.
Is this possible with vba.
Thanking all in advance for answer.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi there

Any reason for doing this? It is a bit risky seeing as you might code wrong somewhere and then would need to fix repair Excel...
 
Upvote 0
Hi there
Yes
Many cells in those sheets automatically pops up a dropdown list when selected. Every time a have selected/entered in a cell i dont want to by default have the next pop up in my face.
Thank you for asking
 
Upvote 0
Ok... and should this be on Enter button or Tab button?
 
Upvote 0
Right click on Sheet6/ view code, then paste below code into:

VBA Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
Target.Select
Application.EnableEvents = True
End Sub

Same process for sheet7
 
Upvote 0
Here is a sample for Tab and Enter keys.
Place the following procedures in a sheet module for Sheet6 and Sheet7.
If you really want to control users' behavior, need to handle other keys such as allow keys. It seems to be a hassle. :)

VBA Code:
Private Sub Worksheet_Activate()
    Application.OnKey "{TAB}", ""
    Application.OnKey "~", ""    'Enter
    Application.OnKey "{ENTER}", ""    'Enter in Numeric keypad
End Sub

Private Sub Worksheet_Deactivate()
    Application.OnKey "{TAB}"
    Application.OnKey "~"    'Enter
    Application.OnKey "{ENTER}"   'Enter in Numeric keypad
End Sub
 
Upvote 0
Thank you for all answers
will try all as soon as possible
Is it possible to deactivate on leaving the sheet automatically?
 
Upvote 0
I realize now that it is actualy on pressing enter I want to remain in cell and not when pushing TAB
Sorry for mislead
When I press on other sheets I would like to return to normal (move one down after enter)
 
Upvote 0
I believe that it would work as intended. Just try to delete some lines related to Tab from the procedures that I posted. Have you tried our codes?
 
Upvote 0
Solution

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,094
Latest member
teemeren

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