+ Reply to Thread
Results 1 to 5 of 5

Move cursor to specific cell after Enter whether or not data's input, in protected sheet

  1. #1
    Registered User
    Join Date
    04-06-2014
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    3

    Move cursor to specific cell after Enter whether or not data's input, in protected sheet

    Hi all,

    I've looked all over this board and the web and can't find the answer to this exact problem.

    In a protected sheet, the unlocked cells are columns B through L. If the cursor is within columns E through L, after hitting Enter I need the cursor to move to cells in a particular column (to be exact: it needs to go one row down, column E).

    I've figured out that if I do this...:

    Please Login or Register  to view this content.
    ... I get half of the desired effect. Hitting Enter after inputting data in columns E through L takes me to the next row, column E.

    However, I also need to be able to jump to the same place if I click on a cell (or tab to it) without inputting data (it may already have data, or may be blank), and hit Enter. What do I need to add / change?

    The sheet's protected, some cells are locked and I can't use arrow keys or tab to get to the desired cell (the spreadsheet's been used for years, the users want "Enter", period). It has to be "hit Enter (with or without inputting data), go to row + 1, column E".

    Thank you for any suggestions!

    Kirk

    Edit: it needs to work in Excel 2007 up to 365.
    Last edited by kirkub; 04-06-2014 at 05:20 AM. Reason: Added version number

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Move cursor to specific cell after Enter whether or not data's input, in protected she

    First, you have done this the hard way--your code can be simplified to this:

    Please Login or Register  to view this content.
    I also need to be able to jump to the same place if I click on a cell (or tab to it) without inputting data (it may already have data, or may be blank), and hit Enter.
    There are two types of events that are relevant. First is the Worksheet_Change event that you already have. This will capture any time that the content of a cell is changed by the user. The other is Worksheet_SelectionChange. This will detect any time the selected cell changes. So it will detect if the user hits Enter without changing anything, because when you hit Enter, Excel moves you to another cell. It also acts if you merely tab to or click on a cell--in that case it doesn't wait for you to hit Enter. Your description says you want to do this after the user hits Enter but I suspect what you really need is to change cells if the user merely selects one of these--not really needing to hit Enter. So try this, which is exactly the same code but using SelectionChange:

    Please Login or Register  to view this content.
    Edit: Added red code to avoid event loop
    Last edited by 6StringJazzer; 04-06-2014 at 07:58 AM. Reason: Added red code
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    04-06-2014
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Move cursor to specific cell after Enter whether or not data's input, in protected she

    6StringJazzer / Jeff,

    first off - thank you for simplifying the code. It was my first piece of VBA in several years!

    However, the updated (second) code doesn't work for me. It makes data input impossible (because it jumps one row immediately, before I even start entering data!), it makes selection of cells impossible (clicking on them makes the cursor jump immediately), and I can't use arrow keys (using them makes the cursor jump immediately) or tab (same result). Basically, no matter what I want to do, it merely moves the cursor to column E.

    I need to be able to select cells to correct them. I need to be able to tab over the cells (or click on them), and if they're correct - hit "Enter" without inputting data, and that should cause "one row down, column E". If they're incorrect, then I input the data, and the first code does work, because there was input.

    So there has to be another way... I hope!

    Thank you,

    Kirk

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Move cursor to specific cell after Enter whether or not data's input, in protected she

    There is no built-in event that fires any time you are in a cell and do nothing else except hit ENTER.

    I think it is possible to create code that detects a specific keystroke, such as ENTER. However, I have never had a need to do that so have no experience with it. I think that is the only possibility left for what you want to do.

  5. #5
    Registered User
    Join Date
    04-06-2014
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Move cursor to specific cell after Enter whether or not data's input, in protected she

    6StringJazzer,

    thank you for your reply! Looks like I'm going to have to settle on one of two work-arounds:

    1) use the first code, and if someone clicks or tabs over to a cell and does nothing in it, s/he will have to "manually" go to the next cell s/he needs;

    2) allow the users to Select Locked Cells under Protection; this always returns the cursor to column E after hitting Enter, whether or not data has been input. Of course that means users will be trying to type in the locked cells sometimes, and getting the error window

    Thank you again!

    Kirk

    Correction: the first code above does NOT work properly: you can't use Tab after entering data to move to the next field to the right. Instead, you end up in column E. Basically, disregard the code.
    Last edited by kirkub; 04-06-2014 at 09:03 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 11-18-2013, 04:18 PM
  2. Move after Enter wont disable in protected sheet
    By rtullier in forum Excel General
    Replies: 2
    Last Post: 02-12-2013, 06:32 PM
  3. 'Move Selection after Enter' when sheet is Protected
    By kilgrow.jp33 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-08-2011, 05:51 PM
  4. Hitting Enter to Move Cursor to the Next Entry Cell
    By Cisnerax in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-25-2006, 07:10 AM
  5. [SOLVED] In a protected sheet how do I get the cursor to only move to unlo.
    By PapaBear in forum Excel General
    Replies: 2
    Last Post: 04-22-2005, 05:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1