#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default increase cell value

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??
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default increase cell value

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.
--
Gary's Student


"Hottshot8226" wrote:

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??

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom functions calculating time arguments Help Desperate Bill_De Excel Worksheet Functions 12 April 25th 06 02:22 AM
increase the value of a cell by a percentage ba Excel Discussion (Misc queries) 2 January 5th 06 10:29 PM
Instead of a negative number, I'd like to show zero... Dr. Darrell Excel Worksheet Functions 6 December 7th 05 08:21 PM
Possible Lookup Table Karen Excel Worksheet Functions 5 June 8th 05 09:43 PM
I need to increase a number which is held in a cell by 1 Steve New Users to Excel 1 January 14th 05 12:07 PM


All times are GMT +1. The time now is 10:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"