How to use Excel to tally without pressing the enter key

Greg Moore

New Member
Joined
Jul 23, 2024
Messages
3
Office Version
  1. 2021
Platform
  1. Windows
Hello,
I would like to use Excel to tally counts that I do. In an ideal setting I would place the cursor in A1 and enter multiple characters such as "///.,,./" to represent different items. I can get a running count if I press the enter key after each character click or at the end. My problem is that I want to update the tally with each key stroke so I can see when I reach 100 without pressing the enter key.

Any assistance is appreciated.

Greg
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Welcome to the Forum!

Perhaps something along these lines? (I have used the down arrow key as the counter)

VBA Code:
Sub StartTally()

    Application.OnKey "{Down}", "Tally"

End Sub
Sub StopTally()

    Range("A1").ClearContents
    Application.OnKey "{Down}"

End Sub
Sub Tally()
    
    Range("A1").Value = Range("A1").Value + 1

End Sub

This can easily be expanded for simultaneous tallies of more than one item. The question wasn't completely clear on this point.
 
Upvote 0
Solution
It is good to be part of the forum.

Very appreciative of your help. I played around with the macro and came up with the following. It facilitates multiple simultaneous tallies and will work well as is, but I have one remaining question. Instead of the B, N, and M keys, is it possible to code for the comma, period and forward slash keys to be used? Tried to directly substitute them into the code, but didn't work.

1721791807708.png
 
Upvote 0
Just wrap in brackets, e.g.

Application.OnKey "{/}", "Tally"

You will probably find that "/" brings up the keyboard shortcuts menu. To stop this happening, go to the end of File/Options/Advanced and clear the box that says "Microsoft Excel menu key" (assuming you're happy not to have this functionality).

1721792958496.png
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top