Update totals

  • Thread starter Thread starter Gareth
  • Start date Start date
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
 
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.
 
Back
Top