Hi,
Start with this procedure:
- Code: Select all
Private Sub Workbook_Open()
Msgbox "Workbook is opening"
End Sub
Try it out. Every time you open the workbook you should see this message. If you don't you have done something wrong.
Now take out the code for the message box and insert this code instead:
- Code: Select all
Application.OnKey "{F1}", "ShowSheet1"
You know that this code will run when you open the workbook because you tested your Open Event procedure. But you can't run it because you don't have the procedure ShowSheet1 yet. So, insert an apostrophe before the line so that you can still open and close your workbook without getting error messages. Remove the apostrophe when your procedure is ready.
You will have to make a separate procedure for each key you want to assign a function to, and a separate OnKey call for it in the same Open event procedure. So, you now settle down to write the procedure to show Sheet 1. I can't help you with that because I don't understand your problem. My tablet is an iPad. It has no Function keys and I can't load Excel workbooks on it.
But I would like to add one word of caution:
Once you assign another function to F1 the original function is lost and you should think of how to get it back. The way to do it is to run another event procedure when you close the workbook. It would be nice if you would have a command that you can run there that resets all your buttons to their original defaults. If not, you may have to write a separate procedure for each button to tell it to do what it used to do before.
Have a great day!
Sisyphus
I do this for "honour and country" - much less of the latter, actually.
If I helped you, award points, plenty of them.
If I bored you, deduct points for being too long-winded. (I know, :lol)