Thursday, 7 August 2025

HOW TO USE VBA CODE AND ASSIGN A MACRO WITH A SHOTCUT KEY

STEPS:

  1. Open the document or template where you want this shortcut key functionality.
  2. Record the Macro:
  3. Press Alt + F8 to open the Macros dialog.

If you have vba code:

  1. click on developer tab
  2.  click on the record macro and  giev a name and saved it.
  3. click on stop recording
  4. go to Macros
  5. click your desired macro
  6. click on edit
  7. write or paste your vba code 
  8. ctrl +S
  9. closs all and save.

Assign the Macro to a Shortcut Key:

  1. Go to File > Options > Customize Ribbon > Keyboard Shortcuts: Customize (at the bottom).
  2. In the "Categories" list, select Macros.
  3. Select your MACRO from the list of macros.
  4. In the "Press new shortcut key" field, press your desired shortcut key (e.g., Ctrl + Alt + F), press those keys simultaneously not one by one.
  5. Click Assign, then Close.
  6. Save the Changes:
  7. Save the document as a macro-enabled file (*.docm) if you want to use this feature only in this document.
  8. Alternatively, save it in the Normal.dotm template to use the macro across all documents.


Using the Shortcut:

Press your assigned shortcut key (e.g., Ctrl + Alt + F), and your macro automatically run.


IF YOU HAVE MORE THAN 1 MACRO , IT APPEARS LIKE THIS SEPARATED BY LINE.

It is the vba(visual basic code) interface showing 2 macros separated by line, each macro allots a shortcut key


#msexcel #coding Dynamic Buttons

No comments:

Post a Comment

thank you for your feedback