+ Reply to Thread
Results 1 to 8 of 8

SendKeys Problem

  1. #1
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    SendKeys Problem

    Hi,

    There are 2 Macros in the attached file.

    Elm1 is the "elegant" one which works perfect.

    As I'm studying VBA (by myself) I came across the SendKey command - so I tried to implement the {DOWN} command but with no success (see Elm2).

    It is important for me to understand why Elm2 - as is - does not present the same results like Elm1.

    (Every Macro should be executed 5 times).

    I'm familiar with the fact the SendKeys should not be run from within the VBA Editor (with F8 or F5) and therefor I declared the Ctrl+Shift+O shortcut to Elm2 Macro.

    Thanks in advance for any assistant, have a nice weekend

    Elm
    Attached Files Attached Files

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524
    I assume it is because you are in still in the copy/paste command
    Here are other options
    Please Login or Register  to view this content.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello ElmerS,

    The reason your code didn't go down to the end of the range is simple. If you want to advance one row on the worksheet, press the Down Arrow. To go to the end of the column requires 2 keys: END and the DOWN ARROW. Also, for SendKeys to work, the worksheet must be visible to you. Here is simple macro to go down to the end of a column.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  4. #4
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412
    Dave & Leith,

    Thanks for your efforts.

    I do hope you checked out the attached WB.

    Elm1, which works fine, has and needs 2(!) VBA command only.

    Elm2 is my problem.

    I did not asked for a solution - Elm1 is the best and shortest solution.

    In addition - elm1 finds the last cell "very easily" without any Sendkeys.

    My question and request is to know why the Down-Arrow sendkeys command does not work.

    The sheet was visible when I pressed Ctrl+Shift+O.

    Please, try to understand my question as it is very simple.

    I want Elm2 to do EXACTLY what Elm1 does.

    You may change some of the commands as long as the Application.SendKeys ("{DOWN}") - remains in that code.

    I started this task by recordind the various steps.

    The Down-Arrow was recorded as: Range("xx").select

    This is the command that I want to change to the Application.SendKeys ("{DOWN}").

    I repeat that this is not a "looking for a solution" Question (as Elm1 provides all I need) - it is simply a wondering out of curiosity question.

    Thanks for your efforts,

    Elm

    bth: I didn't get any E-Mail notification, like in the past, for both your posts - although Notification Type is: Instant email notification

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello ElmerS,

    If you read my post, you will find the explanation as to why the SendKeys wasn't working correctly. You failed to include the End key in the string.

    Sincerely,
    Leith Ross

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524
    Quote Originally Posted by ElmerS View Post

    You may change some of the commands as long as the Application.SendKeys ("{DOWN}") - remains in that code.


    I don't intend on changing anything, the question was answered...

  7. #7
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412
    Sorry, Dave,
    My question was not answered by you.
    I didn't ask how to get to the last full cell in the column.
    I asked why from that point the: Application.SendKeys ("{DOWN}") does not move the cursor.
    I didn't ask for a "workaround" as Elm1 does all I need in the simplest way.
    **********************************************************************************

    EDITED !!!

    Thank you, leith, for being patient.

    The following code works fine - tested a few sequential times BUT has one "minor" problem.
    At the first run - assume range A1:A10 has values - it overwrites Cell A10.
    From the second run and on, it PASTES the copied value into the next empty cell.

    Please Login or Register  to view this content.
    If there is a logical explanation - I'll be glad to learn.

    Thanks again, Elm
    Last edited by ElmerS; 01-24-2009 at 08:15 PM.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I don't understand why you want to use SendKeys, most programmers avoid these commands especially when there is a different way available.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ 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