increase cell value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do i create a macro to increase a cell value by a variable number. say
the cell is 12 i want to add 3 to it just by typing in 3 instead of 15. is
that possible??
 
Put the following in worksheet code:


Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Intersect(Target, Range("A1")) Is Nothing Then
Application.EnableEvents = True
Exit Sub
Else
Range("A1").Value = Range("A1").Value + memory
memory = Range("A1").Value
End If
Application.EnableEvents = True
End Sub

Put the following in a standard module:

Public memory
Sub ordinate()
memory = 0
End Sub

This uses cell A1 as an example. Whatever you enter in A1 will be added to
the previous contents.


Run ordinate to clear the memory.
 

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