+ Reply to Thread
Results 1 to 13 of 13

Go to certain cell on pressing return in a range

  1. #1
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Go to certain cell on pressing return in a range

    In the range I4:I300 , I'm trying to select the cell which is one below in the range D4:D300 once I press return.

    For example , I would make my entry to I10 and press return. The cursor would then go to D11. A return on I234 would select cell D235 , and so on.

    Can someone advice how to achieve this with VBA?

    Grateful for any help.

    Using Excel , Word and Access 2003 - For the whole of 2024

  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: Go to certain cell on pressing return in a range

    Put this code in the VBA module for the worksheet that contains the cells you are talking about:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Go to certain cell on pressing return in a range

    Thanks for getting back , and for the coding.

    It's working when I select the cell and moving automatically without allowing any entry to the cell. I do need to put an entry in the cell in the range I4:I300 , and only move to D when return is pressed.


  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,492

    Re: Go to certain cell on pressing return in a range

    Maybe better changing it to a Worksheet Selection Change Event handler then.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Go to certain cell on pressing return in a range

    Thanks . I've tried it in various events. No joy I'm afraid. (:

    I'm selecting cell I36 for example and it's going to G37 rather than D37 as desired. On return the WS is shifting to the right also.

    Ideally I'd like to chose for example I45 and make an entry. On pressing return D46 would be selected with no other movement in the WS. Grateful for your time and expertise.
    Last edited by CDandVinyl; 01-16-2021 at 08:44 PM.

  6. #6
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: Go to certain cell on pressing return in a range

    The code TMS provided does exactly as you have described in your requirements, except for the fact he got the column wrong by one.

    Try changing the '-6' to '-5' and it should give you what you want.

  7. #7
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Go to certain cell on pressing return in a range

    Ok thanks. I changed -6 to -5 and that's fixed it. It's working fine now. A return in the range I4:I300 is moving the cursor to the correct position in D.

    Unfortunately , as I is the last column to the right on my worksheet , hitting return in I throws the whole screen to the right. It moves the WS to show empty columns J and K. So the cursor is going left to D , but the screen is going right (!).

    Is there a way with VBA to fix this so the screen stays still when i make a return in I?
    Last edited by CDandVinyl; 01-16-2021 at 10:33 PM.

  8. #8
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: Go to certain cell on pressing return in a range

    Can you put the sample workbook up (as per the yellow banner at the top of the page)?

  9. #9
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Go to certain cell on pressing return in a range

    I found a solution in setting

    Please Login or Register  to view this content.
    to limit the scroll on the page.This does the trick.



  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,492

    Re: Go to certain cell on pressing return in a range

    @CDandVinyl: Thanks for the rep.

    @Croweater: I can't take credit for the code; that was provided by 6SJ.

  11. #11
    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: Go to certain cell on pressing return in a range

    Sorry for the error in the offset value.

    There is no scrolling on my sheet, maybe because my monitor is bigger. On my sheet I see columns A:AC.

  12. #12
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: Go to certain cell on pressing return in a range

    Quote Originally Posted by TMS View Post
    @CDandVinyl: Thanks for the rep.

    @Croweater: I can't take credit for the code; that was provided by 6SJ.
    Yeah...my mistake. Apologies for that.

  13. #13
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,492

    Re: Go to certain cell on pressing return in a range

    @Croweater: no worries.

+ 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. [SOLVED] Why is this happening? Pressing Delete extends range for code?
    By adamtzvi in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-05-2020, 06:26 PM
  2. Replies: 9
    Last Post: 11-18-2019, 10:10 AM
  3. Replies: 3
    Last Post: 11-02-2018, 11:59 AM
  4. Replies: 1
    Last Post: 09-14-2014, 02:10 PM
  5. Replies: 6
    Last Post: 06-05-2014, 05:02 PM
  6. Replies: 0
    Last Post: 05-09-2012, 09:26 AM
  7. Forcing data entry by pressing return
    By Simon1185 in forum Excel General
    Replies: 3
    Last Post: 10-22-2010, 05:28 AM

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