• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro shortcut in VBA

dolphintabby

New Member
Hello, I have been using Excel for quite sometime but am new to the VBA side of it. :) I am trying to create a Macro using VBA and The 1st Macro I created using just record works fine. When I tried to create a 2nd Macro in the same worksheet but using VBA instead of record and I assign it a shortcut key the shortcut key for the 2nd Macro won't work and for some odd reason the name keeps auto populating with the workbook name.the name I selected for the Macro-for example 'MyNameTest.xls'!'.ColorMeRed and the short cut key should be Ctrl+Shift+J when I press those keys it gives me a ping sound and does nothing. If I go to the developer tab and press Macro and select run it works fine. If anyone could please help I would greatly appreciate it. :)
 
Hi Dolphintabby


What you have inadvertently done is put the macro in the workbook MyNameTest.xls. Your short cut key will only work within this workbook. Go to the MyNameTest.xls workbook cut ColormeRed and paste put it under the recorded macro in the workbook you want to run the code from. Then go to Developer (XL10) macros – highlight ColorMeRed - click Edit. Now add your desired short cut key. This should fix your problem :)


Take Care


Smallman
 
Hi ,


If you have more than one workbook open , then when you look at the macros available , the name will be prefixed with the file name. There is nothing wrong in this.


If all your workbooks have been opened in the same instance of Excel , then pressing the short-cut key from any workbook will still run the macro , but it may not do anything , since references to cells will all be interpreted with respect to the workbook from which you have pressed the short-cut key.


If your workbooks have been opened in different instances of Excel , then pressing the short-cut key from a different workbook will not run the macro. However , in this case , the macro you wish to run will not be displayed in the list of macros when you click on the Macros button.


Can you close all open workbooks except the one which has the macro , press the short-cut key , and see what happens ?


Narayan
 
Thank you both for your input. I only have the one workbook open but the short cut key is still now working.

@small man I didn't know where to cut the workbook name from?

Thank you again for trying to help. :)


~Dee :)
 
Back
Top