+ Reply to Thread
Results 1 to 3 of 3

[SOLVED] Return alt-enter when enter is pressed in a specific cell

  1. #1
    Registered User
    Join Date
    02-05-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    2

    Question [SOLVED] Return alt-enter when enter is pressed in a specific cell

    I have a spreadsheet where the user is supposed to enter text into a specific cell. That text may be a single sentence, or it may be several paragraphs. I want Excel to convert the enter key to a carriage return and cause the cursor to stay in the same cell.

    I have something kind of working like I want, but there are still some issues:
    Please Login or Register  to view this content.
    This will add the enter like I want, but exiting out of it is cumbersome; you have to press enter one last time, then escape to jump out of the worksheet_change sub (if you just press escape, you loose the last line).

    I'd like to have the Tab key jump out, or have the escape key work without having to press the proceeding enter.

    Anyone got a better method?
    Last edited by bigsteve; 04-17-2013 at 10:22 AM. Reason: solved my own problem

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Return alt-enter when enter is pressed in a specific cell

    Perhaps you could use a TextBox object from the Drawing toolbar and place it on the worksheet over your cell. Assign a macro to it to paste the text in your cell or do what you need done.

  3. #3
    Registered User
    Join Date
    02-05-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: [SOLVED] Return alt-enter when enter is pressed in a specific cell

    Okay - figured it out after a night's sleep:

    I changed the worksheet_change sub:
    Please Login or Register  to view this content.
    It looks for a switch that I created below.

    and I added this:
    Please Login or Register  to view this content.
    Application.onkey will run a macro (it has to be public and in a module) when a particular key is pressed.

    Then added this to a module:
    Please Login or Register  to view this content.
    This will cause the boolean to switch if the tab key was pressed

    Finally, I put in a code to remove the onkey watch when I leave the page:
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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