If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > F4 to run a macro

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-03-04, 05:04
mp218 mp218 is offline
Registered User
 
Join Date: Mar 2004
Location: Slovenia
Posts: 56
F4 to run a macro

Is it possible to press F4 to run a macro?

Or How can I assign a code on certain key?
__________________
Back to the basics...
Reply With Quote
  #2 (permalink)  
Old 08-03-04, 08:14
DavidCoutts DavidCoutts is offline
Registered User
 
Join Date: Jan 2004
Location: Aberdeen, Scotland
Posts: 1,067
Hi

All you need to do is setup the key probably on the Workbook_Open Event

there you could put the code

Application.OnKey {F4} , "MyMacroName"

this sets up when you press the F4 key it will run the Subroutine MyMacroName

in the Workbook_BeforeClose event use the code

Appliacation.OnKey {F4}

this stops the macro running everytime you press F4 if the Workbook isn't open

HTH

David
Reply With Quote
  #3 (permalink)  
Old 08-04-04, 07:59
mp218 mp218 is offline
Registered User
 
Join Date: Mar 2004
Location: Slovenia
Posts: 56
F4

I tried it and it works perfectly!

thx
__________________
Back to the basics...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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