From: M on 20 May 2010 08:33 Hi, I am trying to automate the following two excel shortcuts using VBA. I know I can use commandbar and commandcontrol to call excel menus but I can not find the submenus these shortcuts belong to. 1. Ctrl + [ -- cursor goes to the precedent cell 2. F5 + Enter -- cursor goes to the original cell Also, is it possible to call an excel shortcut from VBA? I know that one can call a worksheet function from VBA (For example, Application.WorksheetFunction.Fact(5) ). But is there way to call a shortcut, say Ctrl + C from VBA? Thanks, MG. Submitted via EggHeadCafe - Software Developer Portal of Choice Parallel Programming in C# 4.0: A Short Synopsis http://www.eggheadcafe.com/tutorials/aspnet/047afdf6-61ab-4b85-9204-b0f20bdc955a/parallel-programming-in-c.aspx
From: JLGWhiz on 20 May 2010 11:35 VBA is pretty straight forward in moving the cursor to cells. Range("C5").Select The above VBA command puts the cursor in cell C5. You can also use the GoTo method to move the cursor to specific cells. As for the precedent and original cells. You have to define these cells in code with a variable. myPcell = ActiveCell myPcell.Select myPcell variable will hold the address of that ActiveCell, no matter which other cells become the active cell thereafter. So when you select myPcell, it will return to that original active cell. Shortcut keys are usually assigned to functions and procedures (macros) that a user needs to call periodically to perform a specific action in a worksheet. These procedures have a title line with a name that appears in the dialog box which can be displayed by clicking Tools> Macro> Macros in Excel. There is more than one way to call them from VBA. 1. Just the Name macro1 This can be used if there is no argumentr to be passed to the procedure. 2. Using Call Call macro1 When Call is used when passing arguments to be enclosed in parentheses. If you use the key word Call, then you must use the parentheses, even if there are no arguments. 3. Using Run Application.Run("<path>!macro1", <arg>) This method allows you to run a macro from another workbook. These are all explained in more detail in the VBA help files. Just type in keyword Call or Run to view the topic list, then select the topic from the list. "musicgold via OfficeKB.com" <u40543(a)uwe> wrote in message news:a84938e907762(a)uwe... > Hi, > > I am trying to automate the following two excel shortcuts using VBA. I > know I > can use commandbar and commandcontrol to call excel menus but I can not > find > the submenus these shortcuts belong to. > > 1. Ctrl + [ -- cursor goes to the precedent cell > > 2. F5 + Enter -- cursor goes to the original cell > > > Also, is it possible to call an excel shortcut from VBA? I know that one > can > call a worksheet function from VBA (For example, Application. > WorksheetFunction.Fact(5) ). But is there way to call a shortcut, say Ctrl > + > C from VBA? > > Thanks, > > MG. > > -- > Message posted via http://www.officekb.com >
From: Gary''s Student on 20 May 2010 11:48 Just make the VBA do what the shortcut does. CNTRL+[ can be implemented by: Selection.DirectPrecedents.Select -- Gary''s Student - gsnu201003 "M G" wrote: > Hi, > > I am trying to automate the following two excel shortcuts using VBA. I know I can use commandbar and commandcontrol to call excel menus but I can not find the submenus these shortcuts belong to. > > 1. Ctrl + [ -- cursor goes to the precedent cell > 2. F5 + Enter -- cursor goes to the original cell > > > Also, is it possible to call an excel shortcut from VBA? I know that one can call a worksheet function from VBA (For example, Application.WorksheetFunction.Fact(5) ). But is there way to call a shortcut, say Ctrl + C from VBA? > > Thanks, > > MG. > > > Submitted via EggHeadCafe - Software Developer Portal of Choice > Parallel Programming in C# 4.0: A Short Synopsis > http://www.eggheadcafe.com/tutorials/aspnet/047afdf6-61ab-4b85-9204-b0f20bdc955a/parallel-programming-in-c.aspx > . >
From: musicgold via OfficeKB.com on 20 May 2010 14:02 JLGWhiz, Thanks. I know basic fundamentals related to macros in Excel. The shortcuts I mentioned in my original message are Excel shorcuts. I am not able to find the functions underlying them. I want to be able to execute those shortcuts inside a macro. MG. -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.aspx/excel-programming/201005/1
|
Pages: 1 Prev: Autocomplete Custom Functions and functions arguments Next: Calling Excel shortcuts from VBA |