+ Reply to Thread
Results 1 to 10 of 10

I need to change what the "Enter" button does once it reaches a certain cell.

  1. #1
    Registered User
    Join Date
    06-23-2011
    Location
    Cleveland,OH
    MS-Off Ver
    Excel 2010
    Posts
    5

    I need to change what the "Enter" button does once it reaches a certain cell.

    Hi Everyone,

    I just recently got familiar with VBA and I'm trying to figure it if it may be the best solution for me to accomplish my task. I currently use a foot petal to read measurements on a caliper. The foot petal acts as an "Enter" key and once a measurement is recorded it sends it to the spreadsheet and moves down a row. Now after a certain amount of "Enter" hits how can I program Excel, of a working template, to move over lets say a few rows to the right and couple rows up. Once it has done this I would like to continue to keep doing the rows like it did previously.

    Examples would be once I get to A25 to move to B15 and then continue to go B30 and move to D13. Again using the "Enter" to do all this.

    Is it possible, since I mentioned It would be very beneficial if didn't have to go back and check the screen every

    Thanks in advance if anyone can help me get the basics down on this.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: I need to change what the "Enter" button does once it reaches a certain cell.

    Hi,

    Have you tried unlocking those cells and protecting the worksheet with just the 'Select unlocked cells' option set?

    I think pressing Enter will take you through the cells in that order if you do.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    06-23-2011
    Location
    Cleveland,OH
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: I need to change what the "Enter" button does once it reaches a certain cell.

    Dom,

    Thanks for the quick reply. I have not attempted this, I will give it a go here in a few mins. The only Issue i foresee is that I need to repeat the process further down the spreadsheet. Would the menthod still work? Do i need to leave those cells unlocked as-well?

    *edit; the freeze did not work. I could not freeze the sections I needed. Any other suggestions that may work?*
    Dan
    Last edited by Dmaracic; 06-23-2011 at 12:14 PM.

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: I need to change what the "Enter" button does once it reaches a certain cell.

    Worth a try to see if it works before going down the VBA route.

    Dom

  5. #5
    Registered User
    Join Date
    06-23-2011
    Location
    Cleveland,OH
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: I need to change what the "Enter" button does once it reaches a certain cell.

    The freezing did not work. I believe VBA could solve my issue, I just do not know how to set it up myself and my knowledge is limited currently.

    Dan

  6. #6
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: I need to change what the "Enter" button does once it reaches a certain cell.

    Dmaracic,

    Attached is a sample workbook using the example you specified in your original post:
    Examples would be once I get to A25 to move to B15 and then continue to go B30 and move to D13. Again using the "Enter" to do all this.


    The code acting in Sheet1 is:
    Please Login or Register  to view this content.


    With that, the cursor will move to the desired cells using only the Enter key.

    Hope that helps,
    ~tigeravatar
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    06-23-2011
    Location
    Cleveland,OH
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: I need to change what the "Enter" button does once it reaches a certain cell.

    Thank you tigeravatar, It works but only on your spreadsheet maybe 2010 has some compatibility issues. I'll try and see if it works for me tonight, I'll update in the morning.

    Dan

  8. #8
    Registered User
    Join Date
    06-23-2011
    Location
    Cleveland,OH
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: I need to change what the "Enter" button does once it reaches a certain cell.

    Tigeravatar,

    This is what I'm working with. Code should be in there as-well.

    Every red line i want it to go a green. following your example i added extra rows to make the macro work. In your template it works just fine, In mine it does not however.

    Thanks for the help once again
    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: I need to change what the "Enter" button does once it reaches a certain cell.

    Dmaracic,

    Right away I can tell you the issue is because of merged cells. When you go to a merged cell, it automatically selects both of them, which means Target.Cells.Count > 1, which is causing this line to return TRUE and then exit the subroutine:
    Please Login or Register  to view this content.

    Deleting that part of the line lets the macro run, but the fact that you're using merged cells is messing it up altogether. If you can adjust your sheet to not have merged cells, it should work for you

    ~tigeravatar

  10. #10
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: I need to change what the "Enter" button does once it reaches a certain cell.

    Please Login or Register  to view this content.
    will result in C13, E24,etc.



+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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