Assign F1 as a macro?

  • Thread starter Thread starter Ryk
  • Start date Start date
R

Ryk

I have made this from a old post, but it doesn't work, the help screen
comes up...any ideas why?

Option Explicit
Sub DownRow()
Range("G" & ActiveCell.row + 1).Select
End Sub
Sub F1On()
Application.OnKey "{f1}", "DownRow"
End Sub
Sub F1Off()
Application.OnKey "{f1}"
End Sub

Its modified from a Dave Pederson answer in another post.

Ryk
 
It works for me. Did you run F1On before trying to use F1?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Ryk

Works fine in my Excel 2003.

Where did you enter the code?

Does the macro DownRow work on its own?

All 3 should be placed into a General module.

F1On must be run first to set the F1 key to run DownRow macro.


Gord Dibben MS Excel MVP
 
Macro itself works fine, assigned it to a button.
How do i run F1On? I thought macro did all the work?

Ryk
 
It does, but it has to be run somehow.

Either run it manually (Tools>Macro>Macros..., select it from the list, and
hit Run.

or put it in the Workbook Open


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call F10Off
End Sub

Private Sub Workbook_Open()
Call F10On
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
I added this....in the this workbook spot... modified it to be F1 not
F10.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call F1Off
End Sub


Private Sub Workbook_Open()
Call F1On
End Sub


Get sub or function not defined error.
 
Ok Ok , seems I am not the brightest bulb, got confused, then it
dawned, run the F1On macro, to assign it heheh. Works awesome, thanks
guys.

Ryk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top