+ Reply to Thread
Results 1 to 3 of 3

The application SendKeys

  1. #1
    Registered User
    Join Date
    01-21-2004
    Posts
    21

    The application SendKeys

    Hi everybody,

    My question is about using the application SendKeys with IF inside VBA, I have a table contains twenty rows and five columns (File Attached), what I want is that when any of the twenty cells in column "C" is not blank, Then: By using the application SendKeys, the current date should be inserted in the opposite cell in column "D".

    I have created a code for that purpose, but it did not work properly, so I wish I could find the answer in this wonderful site.

    And this is the code I have created:

    PRIVATE SUB WORKSHEET_CHANGE(BYVAL TARGET AS RANGE)
    IF RANGE("C" & TARGET.ROW).VALUE <> "" THEN
    RANGE("D" & TARGET.ROW).VALUE = APPLICATION.SENDKEYS("^;")
    EXIT SUB
    END IF
    END SUB
    Attached Files Attached Files

  2. #2
    K Dales
    Guest

    RE: The application SendKeys

    First: Application.SendKeys does not give you a value you can assign to a
    range, as you are trying to do; instead you would need to make the desired
    cell the active cell and then use SendKeys to type the string "^;" into it,
    but...

    Next point: it is not necessary or even advisable to use SendKeys for this;
    just get today's date with the Date() function:
    IF RANGE("C" & TARGET.ROW).VALUE <> "" THEN
    RANGE("D" & TARGET.ROW).VALUE = DATE()
    --
    - K Dales


    "Jim333" wrote:

    >
    > Hi everybody,
    >
    > My question is about using the application SendKeys with IF inside VBA,
    > I have a table contains twenty rows and five columns (File Attached),
    > what I want is that when any of the twenty cells in column "C" is not
    > blank, Then: By using the application SendKeys, the current date should
    > be inserted in the opposite cell in column "D".
    >
    > I have created a code for that purpose, but it did not work properly,
    > so I wish I could find the answer in this wonderful site.
    >
    > And this is the code I have created:
    >
    > PRIVATE SUB WORKSHEET_CHANGE(BYVAL TARGET AS RANGE)
    > IF RANGE("C" & TARGET.ROW).VALUE <> "" THEN
    > RANGE("D" & TARGET.ROW).VALUE = APPLICATION.SENDKEYS("^;")
    > EXIT SUB
    > END IF
    > END SUB
    >
    >
    > +-------------------------------------------------------------------+
    > |Filename: SendKeys.zip |
    > |Download: http://www.excelforum.com/attachment.php?postid=3695 |
    > +-------------------------------------------------------------------+
    >
    > --
    > Jim333
    > ------------------------------------------------------------------------
    > Jim333's Profile: http://www.excelforum.com/member.php...fo&userid=5186
    > View this thread: http://www.excelforum.com/showthread...hreadid=396075
    >
    >


  3. #3
    Registered User
    Join Date
    01-21-2004
    Posts
    21
    Hi,

    Thank you for your reply, but the code you delivered is not what I want excalty. The date updates daily while I want it to stay as it was inserted at the first time and that is why I asked to insert it by using SendKyes Application.

    Do you have another way???

+ 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