Assign new shortcut to tab through worksheets

jcoop3r

New Member
Joined
Apr 5, 2011
Messages
1
Hi message board,

I would like to assign the function of tabbing through worksheets to CTRL + Right / Left. I know this is already possible with CTRL + Page up / down, but I want to make life easier for myself =)

Any ideas? I can use VBA script so a technical answer is fine

Regards,

James
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hi James,

I assume you mean Ctrl-Right Arrow, etc. You can do this using the following code:

Code:
Sub ActivateWorksheetToRight()
   If ActiveSheet.Index < Sheets.Count Then
      Sheets(ActiveSheet.Index + 1).Activate
   End If
End Sub

Sub ActivateWorksheetToLeft()
   If ActiveSheet.Index > 1 Then
      Sheets(ActiveSheet.Index - 1).Activate
   End If
End Sub

Sub SetKeys()
   Application.OnKey "^{RIGHT}", "ActivateWorksheetToRight"
   Application.OnKey "^{LEFT}", "ActivateWorksheetToLeft"
End Sub

Sub ResetKeys()
   Application.OnKey "^{RIGHT}"
   Application.OnKey "^{LEFT}"
End Sub

First, run the SetKeys macro. This assigns the Ctrl-Right and Left arrow key sequences to the two macros. When you are done and want to return the Ctrl-Right and Left arrow keystrokes to their default settings run the ResetKeys macro.

Of course, you can use this method to set just about any keystrokes to accomplish the page tabbing. I personally use Ctrl-Right and Left arrows quite a bit as I find their default functions to be quite useful, so I would be inclined to instead use something like Ctrl-+ and Ctrl-- (Control Plus and Control Minus) for the page tabbing.

Keep Excelling.

Damon
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top