Sum, count or some function that will accumulate in one cell

  • Thread starter Thread starter Deb
  • Start date Start date
D

Deb

First, thanks in advance to anyone who can help me with
this (probably simple and I just don't get it). I am
trying create a simple list of items such as car parts
and the result be a cumulative total by day for each
part. The trick is I'd like to go through a bunch of hand
written tickets and keep typing the number into the cell
for mufflers for instance. So in Column A, I have
mufflers, air filters, water pumps, etc. Then for today,
Feb 4th, I'll have a bunch of hand written tickets and
I'd like to go through each ticket and add the number of
mufflers in a single cell. If I have 4 of a part on one
ticket, I'd enter 4 and then have another ticket with
another muffler, I'd like to type 1, then it would turn
to 5 and have the number in the cell Under the column Feb
3rd, in the row of muffler automatically tally the
numbers. Don't know what I've done wrong but can't make
it work.
 
Deb,

You will need VBA to do this. Here is some code that will do it for a value
in column C

Dim nPrev As Double

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit
With Target
If .Column = 3 Then
If IsNumeric(.Value) Then
.Value = .Value + nPrev
Else
.Value = nPrev
End If
End If
End With

ws_exit:
Application.EnableEvents = True
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 3 Then
nPrev = Target.Value
End If
End Sub

To input the code, select your worksheet, right-click on the sheet name tab,
and pick the View Code option. Then paste the code in.

If you want some other column, just change the Column = 3 to the column
number.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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

Back
Top