Adding to current cell value.

hoosali

New member
Local time
Today, 14:26
Joined
Apr 30, 2009
Messages
3
hello all,

for my vba project i am looking to "subtract a value of 1" to a certain cell everytime i press a "button"

for example if i start at 12

press button once = 11
press button twice = 10
press button thrice = 9

and so on..

any help is appreciated.

thanks!
 
hello all,

for my vba project i am looking to "subtract a value of 1" to a certain cell everytime i press a "button"

for example if i start at 12

press button once = 11
press button twice = 10
press button thrice = 9

and so on..

any help is appreciated.

thanks!

The approach should be straightforward as long as you know the basics of Access VBA

  • Use the On_Click Event of the TheButton
  • Reset value of Me.CertainCell (Me.CertainCell = Me.CertainCell -1)
Of Course, an assumption has been made that Me.CertainCell is defined as an Integer. Also, TheButton, and CertainCell are names that I made up and you will need to substitute your own Field names before the code can be meaningful to you.
 
Since you mentioned 'cell', are you doing this in Access or Excel?
 
ActiveSheet.Range("A1").Value = ActiveSheet.Range("A1").Value - 1 'Assuming A1 is your cell. Replace with the actual

or

ActiveSheet.Cells(rowNum, colNum).Value = ActiveSheet.Cells(rowNum, colNum).Value - 1
 

Users who are viewing this thread

Back
Top Bottom