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
 

Some videos you may like

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Damon Ostrander

MrExcel MVP
Joined
Feb 17, 2002
Messages
4,239
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
 

Watch MrExcel Video

Forum statistics

Threads
1,109,379
Messages
5,528,349
Members
409,817
Latest member
JiNXX9500

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top