Tally feature

G

Guest

I was wondering if Excel had a feature where you could program a couple keys
on the keyboard to tally a value in predetermined cells. For example, I will
be counting sperm cells and would like to push 1 if it is living and 2 if it
is not and these keys would correspond to two excel cells where it would
record how many times I push 1 and 2 separately.
 
N

Neil

Lindsay Dale said:
I was wondering if Excel had a feature where you could program a couple
keys
on the keyboard to tally a value in predetermined cells. For example, I
will
be counting sperm cells and would like to push 1 if it is living and 2 if
it
is not and these keys would correspond to two excel cells where it would
record how many times I push 1 and 2 separately.
just an idea from an excel noddy ...
can you make a couple of macros, each incrementing specified cells
(presumably a bit of VB?), and bind a couple of convenient keys tocause the
macros to run ?
hth
Neil
 
K

Ken Johnson

I was wondering if Excel had a feature where you could program a couple keys
on the keyboard to tally a value in predetermined cells. For example, I will
be counting sperm cells and would like to push 1 if it is living and 2 if it
is not and these keys would correspond to two excel cells where it would
record how many times I push 1 and 2 separately.
Hi Lindsay,

With the following code, if B1 =1 then every time you press the left
arrow A1 increases by 1 and every time you press the right arrow C1
increases by 1.
To turn the tallying off just change the B1 value to any other value,
then you can zero A1 and C1 and start again.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Select Case Range("B1")
Case 1
Select Case Target.Address
Case "$A$1"
Range("A1") = Range("A1") + 1
Case "$C$1"
Range("C1") = Range("C1") + 1
End Select
Range("B1").Select
End Select
End Sub

The code is an event procedure and has to be pasted into the
worksheet's code module.
To do that just select and copy the code, then right click the
worksheet tab then select "View code" from the pop up menu, then paste
the code into the code module that appears.
The workbook's Security level needs to be no higher than Medium and
Macros have to be Enabled.

Ken Johnson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top