-
Sheet selection + Shortcuts
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.
-
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 use[vba]application.onkey "{F1}", "GoAll"
application.onkey "{F2}", "GoStock"[/vba]In Workbook_beforeclose use[vba]application.onkey "{F1}"
application.onkey "{F2}"[/vba]And in a normal module[vba]Sub GoAll()
worksheets("All").Select
End Sub
Sub GoStock()
worksheets("Stock Ratings").select
End Sub[/vba]Or you could use one key F1 to switch between worksheets. One press selects the other based on the active sheet name.
[vba]Sub Switch()
if activesheet.name = "All" then
worksheets("Stock Ratings").select
else
worksheets("All").select
end if
End Sub[/vba]
Charlize
-
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
-
Here's Charlize's code in a sample.
F1 for All
F2 for Stock Rating
F3 to toggle between these two
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
Thank You mdmackillop.
You've been a great help, as always
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules