+ Reply to Thread
Results 1 to 3 of 3

A macro to append text to cell content

  1. #1
    Dario de Judicibus
    Guest

    A macro to append text to cell content

    I need a macro that add text to active cell content depending on the key
    pressed after macro shortcut.

    For example, if I assign Ctrl-q to that macro, by Ctrl-qa I add [a] to
    active cell content, by Ctrl-qb I add [b], and so forth.

    So, if my current cell contains

    George

    by Ctrl-qa I will have

    George [a]

    Of course I should be able to customize in macro the association between
    letter and text to append. For example:

    a -> [a]
    b -> [b]
    c -> Hurra!
    d-> 13456

    and so forth.

    I tried to modify a recordered macro, but I cannot obtain what I need. Any
    help appreciated.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Dr. Dario de Judicibus - Italy (EU)
    Site: http://www.dejudicibus.it/
    Blog: http://lindipendente.splinder.com
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



  2. #2
    Tom Ogilvy
    Guest

    Re: A macro to append text to cell content

    Unless you wanted to subclass excel and handle all keyboard input, I don't
    think there is an easy way to do that.

    I would recommend that the user do Ctrl-q and in the macro that fires in
    response, the first step would be to put up an inputbox and query the user
    for the letter

    Sub Macro3()
    dim ans as String
    ans = InputBox("Please enter string to append")
    if ans = "" then exit sub
    ActiveCell.Value = ActiveCell.Value & " [" & ans & "]"
    End Sub
    --
    Regards,
    Tom Ogilvy


    "Dario de Judicibus" <nospam@nowhere.com> wrote in message
    news:OxaD$NEaFHA.4020@TK2MSFTNGP09.phx.gbl...
    > I need a macro that add text to active cell content depending on the key
    > pressed after macro shortcut.
    >
    > For example, if I assign Ctrl-q to that macro, by Ctrl-qa I add [a] to
    > active cell content, by Ctrl-qb I add [b], and so forth.
    >
    > So, if my current cell contains
    >
    > George
    >
    > by Ctrl-qa I will have
    >
    > George [a]
    >
    > Of course I should be able to customize in macro the association between
    > letter and text to append. For example:
    >
    > a -> [a]
    > b -> [b]
    > c -> Hurra!
    > d-> 13456
    >
    > and so forth.
    >
    > I tried to modify a recordered macro, but I cannot obtain what I need. Any
    > help appreciated.
    >
    > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > Dr. Dario de Judicibus - Italy (EU)
    > Site: http://www.dejudicibus.it/
    > Blog: http://lindipendente.splinder.com
    > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    >
    >




  3. #3
    Dario de Judicibus
    Guest

    Re: A macro to append text to cell content

    Thank you. I was able to obtain what I needed by changing your sample.

    DdJ



+ 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