Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Excel - is there a way to paste specific values per keyboard shortcut?

I'm working on a project in Excel where I need to repeatedly type 5 different values. Is there a way with a macro or something to paste value a when I type ctrl-a (or whatever), value b when I type ctrl-b, etc? I haven't done macros before, so if that's part of your answer, please point me towards a good how-to for creating macros, too. Thanks!

1 Answer

Relevance
  • BT_Bot
    Lv 5
    6 years ago
    Favorite Answer

    The following is an example of how you can do this using macros:

    1. Open VB editor (Alt+F11)

    2. In VB editor, create a new module (Insert>Module)

    3. In the newly created module, enter the following codes:

    Sub ShrtCutKeysOn()

    Application.OnKey "^a", "Ctrl_a"

    Application.OnKey "^b", "Ctrl_b"

    End Sub

    Sub ShrtCutKeysOff()

    Application.OnKey "^a"

    Application.OnKey "^b"

    End Sub

    Private Sub Ctrl_a()

    Selection = 1234.56

    End Sub

    Private Sub Ctrl_b()

    Selection = "Your text here"

    End Sub

    4. You can modify the code above to your needs. Note that you will have to create a sub for each shortcut you want (5 different values = 5 separate and uniquely named subs). For every shortcut sub that you create you will have to add it to subs ShrtCutKeysOn and ShrtCutKeysOff. The example above assigns values using Ctrl+a and Ctrl+b. Note that if your values are numeric or text then it should be assigned without and with quotes respectively.

    5. Now once your code is all done, close the VB editor (or keep it open and switch to your spreadsheet). From your spreadsheet, run the macro ShrtCutKeysOn (Alt+F8 to open Macro dialog window, then double-click on the macro name or select it then click Run).

    6. Now your shortcut keys should work. The other macro ShrtCutKeysOff will revert the shortcut keys to their defaults (ctrl+A goes back to select all and ctrl+B bold/unbold).

    Hope this was clear and let me know if you have problems modifying the code.

Still have questions? Get your answers by asking now.