Solved

Keyboard short cuts to run macros

Posted on 2011-02-16
5
225 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
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 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

895 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

12 Experts available now in Live!

Get 1:1 Help Now