Reprogram/reassign some function keys in Excel 2007

P

Per Moeller-Olsen

Hi,



We would like to reprogram/reassign Excel 2007 F4 to do something similar to
this:



"From your current selected cell go 6 columns right and make that cell
selected"



I think the code for that is roughly: ActiveCell.Offset(rowoffset:=0,
columnoffset:=6).Select



and with the function key stuff it roughly is: Application.OnKey "{F4}",
"ActiveCell.Offset(rowoffset:=0, columnoffset:=6).Select"



but the OnKey stuff does not work as far as we can tell. They are using
Excel 2007.



1) Any ideas? We have a customer that really would like to
reprogram/reassign some function keys in Excel, will help them a lot.



2) If it does not work with our approached method, can you maybe give
another method for reprogram/reassign the Excel 2007 keys?



Per...
 
D

Dave Peterson

You actually have to reassign the key to a subroutine--not just the code that
you want run.

This would go into a general module:

Option Explicit
Sub auto_open()
Application.OnKey "{F4}", "SelectOver6Cols"
End Sub
Sub auto_Close()
Application.OnKey "{F4}"
End Sub
Sub SelectOver6Cols()
On Error Resume Next
ActiveCell.Offset(0, 6).Select
If Err.Number <> 0 Then
Err.Clear
Beep 'to far to the right already!
End If
 
P

Per Moeller-Olsen

Thx. Will give it a shot when things ease a bit around here with all the
const custmr suprt we get involved in. Per...
 

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

Top