Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using function keys in macros


Is there a way to let the function keys control a macro? For example, I
want to write a program that will run a macro whenever you press F1.
How would I do that?


--
Tha BeatMaker
------------------------------------------------------------------------
Tha BeatMaker's Profile: http://www.excelforum.com/member.php...o&userid=23998
View this thread: http://www.excelforum.com/showthread...hreadid=397040

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Using function keys in macros

See the OnKey method in help. E.g., to assign a macro to F1, use

Application.OnKey "{F1}", "MacroName"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Tha BeatMaker"

wrote in message
news:Tha.BeatMaker.1tzfuc_1124406334.2583@excelfor um-nospam.com...

Is there a way to let the function keys control a macro? For
example, I
want to write a program that will run a macro whenever you
press F1.
How would I do that?


--
Tha BeatMaker
------------------------------------------------------------------------
Tha BeatMaker's Profile:
http://www.excelforum.com/member.php...o&userid=23998
View this thread:
http://www.excelforum.com/showthread...hreadid=397040



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using function keys in macros


I have created a userform, label and macro named UserForm1, lblPress
and Functest respectively. Here is my code.

Private Sub UserForm_Initialize()
Application.OnKey "{F10}", "functest"
End Sub
----------------------------------------------------------------------
Private Sub UserForm_Terminate()
Application.OnKey "{F10}"
End Sub
----------------------------------------------------------------------
Sub functest()
Const conMsg As String = "You have pressed F10"

lblPress.Caption = conMsg

End Su

--
Tha BeatMake
-----------------------------------------------------------------------
Tha BeatMaker's Profile: http://www.excelforum.com/member.php...fo&userid=2399
View this thread: http://www.excelforum.com/showthread.php?threadid=39704

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros will not run with shortcut keys Doug Excel Worksheet Functions 2 December 15th 09 09:33 PM
macros shortcut keys don't work Doug New Users to Excel 0 November 18th 09 03:04 PM
Time keys in macros Sudhir Amin Excel Discussion (Misc queries) 0 August 1st 07 04:36 PM
Macros Shortcut keys WSW Setting up and Configuration of Excel 1 May 14th 06 01:47 PM
listing macros associated with shortcut keys windsurferLA[_2_] Excel Programming 1 January 30th 04 05:32 PM


All times are GMT +1. The time now is 06:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"