[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Keyboard short cuts to run macros

Posted on 2011-02-16
5
Medium Priority
?
237 Views
Last Modified: 2012-05-11
Below are two set of macros; to make selected cells absolute and relative respectively.  I want to add them to the XSTART location so that it forms part of the macros that are available to be used.  What exactly needs to be done so that a keyboard short cut will run either one.  I had this working before, but I do not recall how it was done.
Thanks,
JP
 
Sub MakeRowAbsolute()
    Dim rngCell As Range
    For Each rngCell In Selection
        rngCell.Formula = Application.ConvertFormula(rngCell.Formula, xlA1, xlA1, xlAbsRowRelColumn)
    Next rngCell
End Sub
Sub MakeRelative()
    Dim rngCell As Range
    For Each rngCell In Selection
        rngCell.Formula = Application.ConvertFormula(rngCell.Formula, xlA1, xlA1, xlRelative)
    Next rngCell
End Sub
Sub setKey()
    Application.OnKey "^+%4", "MakeRowAbsolute"
End Sub
What is "^+%4"?

Open in new window

0
Comment
Question by:easycapital
  • 3
5 Comments
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 1000 total points
ID: 34912304
Hope this helps.

http://personal-computer-tutor.com/personalxls.htm

You have to call the line

Application.OnKey "^+%4", "MakeRowAbsolute"

from the workbook open event.

^ stands for control
+ stands for shift

for more on key combination see this,

http://www.rondebruin.nl/key.htm

Sid
0
 

Author Comment

by:easycapital
ID: 34912814
I read the links.  The 2nd link was very helpful to explain the meaning of the control, shift, etc. Thanks!

The first link mentions to place the file in the XLSTART directory - but to avoid depending on the IT department to save it there, I am telling excel to run files in a directory chosen by me.  I can explain where I do this in excel if necessary.  How can I have the embedded file run from that location specified in excel.

Please verify that the macro sets the values as absolute, then it removes the absolute reference if run again.

Thanks,
JP M---Row-anchors-then-remove-it-.xls
0
 
LVL 85

Assisted Solution

by:Rory Archibald
Rory Archibald earned 1000 total points
ID: 34914637
Just put the file in whatever folder you have specified as an alternate startup folder. You also don't really need OnKey - you can simply open the file, open the macros dialog (Alt+f8), select the macro and then click the Options... button and assign the key combination you want.
0
 

Author Comment

by:easycapital
ID: 34915311
Rorya, Good point.  Though I want to assign my macros a Control, Shift, Alt PLUS another key - to help avoid other macros (of course, it may still conflict, but it is a start).  

Could try to make it so that upon hitting Control + Shift + Alt + 4, it makes the selected cells absolute, then the second time, it makes the selected cells relative.

I am very interested start to manage my own set macro short cuts.
Thanks,
JP  
0
 

Author Closing Comment

by:easycapital
ID: 35000508
Thanks,
JP
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question