Keypress Counter 
Author Message
 Keypress Counter

I am only new to excel and not even sure if it is able to do what I am
hoping.

I want to allocate four keys and each time one of these keys is
pressed I want the quanitity in a cell to increase by one.

If this even possible or do I need to look elsewhere.

Thanks
Jim



Tue, 16 Aug 2005 13:33:53 GMT  
 Keypress Counter
Jim

You could put code like this in the ThisWorkbook module (Alt-F11)

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Application.OnKey "a", ""
Application.OnKey "s", ""
Application.OnKey "d", ""
Application.OnKey "f", ""

End Sub

Private Sub Workbook_Open()

Application.OnKey "a", "AddOne"
Application.OnKey "s", "AddOne"
Application.OnKey "d", "AddOne"
Application.OnKey "f", "Addone"

End Sub

Then this in standard module

Sub AddOne()

Sheet1.Range("A1").Value = Sheet1.Range("a1").Value + 1

End Sub

--
{*filter*} Kusleika
MVP - Excel

Post all replies to the newsgroup.


Quote:
> I am only new to excel and not even sure if it is able to do what I am
> hoping.

> I want to allocate four keys and each time one of these keys is
> pressed I want the quanitity in a cell to increase by one.

> If this even possible or do I need to look elsewhere.

> Thanks
> Jim



Tue, 16 Aug 2005 21:51:35 GMT  
 Keypress Counter
Thanks for your reply{*filter*}

I have never used Visual Basic before so this is a little daunting for
me. I played around with the code you gave me and I sort of had some
progress I was able to get the counter to increase by 1 when I ran the
macro but that was it. If I pressed one of the assigned keys I got a
message about not being able to find book 1 add 1.xls or something
similar.

Ultimately what I am trying to acheive is the following. A1 A2 A3 A4
will all be a counter set at 0. Then for example when a is pressed A1
would increase by 1 or if d was pressed a3 would increase by one. This
would loop forever until it is stopped manually.

Any pointers you can give me are greatly appreciated. I have been
thrown in the deep end at work and are trying to find an efficient
solution.

Thanks
Jim

Quote:

> I am only new to excel and not even sure if it is able to do what I am
> hoping.

> I want to allocate four keys and each time one of these keys is
> pressed I want the quanitity in a cell to increase by one.

> If this even possible or do I need to look elsewhere.

> Thanks
> Jim



Wed, 17 Aug 2005 02:11:40 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Field as counter, but no counter

2. Converting from running counters to relative counters

3. Counters - Webot - Access Counters ???

4. hit counter or page counter

5. Field as counter but no counter??

6. Help with Counters (counter logic)

7. In vbs exist the keypress event

8. Keypress event

9. Disabling shift keypress that prevents code execution

10. Capture keypress


 
Powered by phpBB® Forum Software © phpBB Group