Solved

Keyboard short cuts to run macros

Posted on 2011-02-16
5
224 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 250 total points
Comment Utility
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
Comment Utility
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 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks,
JP
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now