I have a spreadsheet with three buttons: Start clock, stop clock, and enter time. Start clock starts a clocktime display in a cell and updates at once per second. Stop clock, stops the clock. Enter time inserts into whatever cell is currently selected the current value in the clock display. Is there a way to map a single keyboard key (say insert) to the enter time button that only works if the clocktime is running, and the mapping ends once stop time is pressed?
Asked
Active
Viewed 151 times
0
-
1Does [this answer](http://stackoverflow.com/a/11154285/4717755) help? I wouldn't think you want to actually map a key, but rather to capture the keystrokes and look for the one you want. – PeterT Jul 07 '16 at 14:35
-
@PeterT I am not sure what you mean by capture the keystrokes. Basically a user selects a cell and then has to press the button with the mouse and id rather they could use a single key ( i can map a ctrl+key option but that is 2 keystrokes) to do so and insert seems the best choice at the moment. – J.Doe Jul 07 '16 at 14:40
1 Answers
0
If you make a public boolean which is set to True when the clock is started and false when it is stopped, then use a key event to detect when the desired key is pressed, you can have the key do whatever it normally does when the timer is not running (boolean = false), and have it instead insert the time when the timer is running (boolean = true)

RGA
- 2,577
- 20
- 38
-
-
@J.Doe Look at the link in PeterT's comment. Capturing keystrokes isn't built-in in excel but its possible if you really need it – RGA Jul 07 '16 at 14:42
-
@J.Doe if you are using a form (as seems to be the case) look at the Accelerator property for form controls. This might do what you are asking – RGA Jul 07 '16 at 14:44