+ Reply to Thread
Results 1 to 6 of 6

Thread: From Active Cell, how to simulate this keystroke

  1. #1
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    242

    From Active Cell, how to simulate this keystroke

    From a current Active Cell, how do you simulate the following Keyboard Keystrokes in the order?
    • Ctrl + Shirt + Down Arrow
    • Shirt + Up Arrow


    I cant quite get it to work out from my current active cell.

    Thanks in advance for looking at this.
    Last edited by clemsoncooz; 01-06-2012 at 03:35 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    12-14-2009
    Location
    San Francisco, CA
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    986

    Re: From Active Cell, how to simulate this keystroke

    I am assuming you meant Shift not shirt.

    Application.OnKey "^+{Down}"

    and

    Application.OnKey "+{Up}"
    To thank someone who has helped you, click on the star icon below their name.

    I hate reading

    Portfolio

    I need a job.
    I am young and incompetent

  3. #3
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    242

    Red face Re: From Active Cell, how to simulate this keystroke

    Quote Originally Posted by JieJenn View Post
    I am assuming you meant Shift not shirt.

    Application.OnKey "^+{Down}"

    and

    Application.OnKey "+{Up}"
    Haha Yes JieJenn....I meant Shift. Thanks for looking at this.

    But that code isnt quite working (at least for me).

    If you look at the attached, sample 1-6-12a.xlsm , let say I want to select the numbers 1 thourgh 18, and assuming my current active cell is already in G4=1, How do I write the code to simulate the keystrokes:
    - Ctrl + Shift + Down Arrow and then releasing Ctrl but still holding shift, press the up arrow.

    Those keystrokes select all the numbers.

    I realize there are others ways to select this data, but the code I am look at will be going into a macro and I dont know where this data is going to be so I cannot use cell references...I just want to simulate that keystroke combo.

  4. #4
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: From Active Cell, how to simulate this keystroke

    Maybe ...

        Range("G4", Range("G4").End(xlDown).Offset(-1)).Select
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    242

    Re: From Active Cell, how to simulate this keystroke

    Quote Originally Posted by shg View Post
    Maybe ...

        Range("G4", Range("G4").End(xlDown).Offset(-1)).Select
    Thanks shg, but I cant hardcode G4, because I am not sure that the date will be in G4. Thatss kind of why I was wondering about it being from the active cell.

    I was thinking something like -
    Range(ActiveCell, Cells(Rows.Count, ActiveCell.Column).End(xlUp)).Offset(-1).Select
    But this code is selecting one too high - It is selecting all the data that I wont, but also including the header.

  6. #6
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: From Active Cell, how to simulate this keystroke

    Range(ActiveCell, ActiveCell.End(xlDown).Offset(-1)).Select
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

+ 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.2.0