PDA

View Full Version : Sheet selection + Shortcuts



GI30065
04-16-2007, 01:49 PM
Hi,

I have a workbook with 10 sheets in it.
2 of those sheets are ALL & STOCK RATINGS.
I need to switch between these 2 sheets very often.
I know excel works with the numbers linked to these names.
Is there a script available, so I can use a shortcut.
Let's say using ctrl + first letter of the sheet, or function keys,...

Thx.

Charlize
04-16-2007, 02:19 PM
You could use the onkey event to change the behavior of a key. F1 for All and F2 for Stock Ratings. In workbook_open event useapplication.onkey "{F1}", "GoAll"
application.onkey "{F2}", "GoStock"In Workbook_beforeclose useapplication.onkey "{F1}"
application.onkey "{F2}"And in a normal moduleSub GoAll()
worksheets("All").Select
End Sub
Sub GoStock()
worksheets("Stock Ratings").select
End SubOr you could use one key F1 to switch between worksheets. One press selects the other based on the active sheet name.
Sub Switch()
if activesheet.name = "All" then
worksheets("Stock Ratings").select
else
worksheets("All").select
end if
End Sub

Charlize

GI30065
04-16-2007, 03:29 PM
I'm sure I'm doing something wrong, coz none works for me.
I've tried then all, and after 1/2h I give up :banghead:

mdmackillop
04-16-2007, 03:56 PM
Here's Charlize's code in a sample.
F1 for All
F2 for Stock Rating
F3 to toggle between these two

GI30065
04-16-2007, 04:29 PM
Thank You mdmackillop.
You've been a great help, as always :rotlaugh: