A macro to append text to cell content

  • Thread starter Thread starter Dario de Judicibus
  • Start date Start date
D

Dario de Judicibus

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 , 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 ->
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
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
 
Thank you. I was able to obtain what I needed by changing your sample.

DdJ
 
Back
Top