Update totals

G

Gareth

I have a sheet which contains data about certain parts of our office. The
data is in range B2:F32.

The data is numeric.

What I would like to do, if possible, is the following:

B2 contains 94, the user wants to add 37 to it by typing 37 over the 94, hit
return and the new total of 131 should appear.

Many thanks in advance.

Cheryl
 
T

Tom Ogilvy

Right click on the sheet tab and select view code. Put is code similar to
this:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo ErrHandler
If Target.Count = 1 Then
If Not Intersect(Target, Range("B2:F32")) Is Nothing Then
If IsNumeric(Target) Then
dblVal = Target.Value
Application.EnableEvents = False
Application.Undo
Target.Value = Target.Value + dblVal
End If
End If
End If

ErrHandler:
Application.EnableEvents = True
End Sub

they would need to enter a negative number to correct mistakes.
 

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