ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   adding a cell to a cell keeping a running total please help (https://www.excelbanter.com/excel-programming/336192-adding-cell-cell-keeping-running-total-please-help.html)

RELWOD85[_5_]

adding a cell to a cell keeping a running total please help
 

im having a bit of trouble with this coding i want to add a value of one
to a cell to keep a running total no matter what number is put into that
cell theres more info down below please could anyone help me?

Private Sub Submit_Click()
Dim x As Integer
Dim one As Integer
Dim two As Integer
Dim three As Integer
Dim four As Integer
Dim five As Integer
one = 1
two = 1
three = 1
four = 1
five = 1

x = Range("a1").Value
Range("a1").Value = Range("a2").Value
Range("a2").Value = x + ActiveCell.FormulaR1C1 = "sum(+1)"

'here instead of swopping the values each time a number one to five is
'entered i want 1 to be added so that cell a2 keeps a running total so
'if 9 was entered into cell a1 then 1 would be added to cell a2 then
if
'7 was entered into cell a1 then 1 would be addedd to the one already
in
'cell a2 making the total in that cell 2

End Sub


--
RELWOD85
------------------------------------------------------------------------
RELWOD85's Profile: http://www.excelforum.com/member.php...o&userid=25753
View this thread: http://www.excelforum.com/showthread...hreadid=392323


Toppers

adding a cell to a cell keeping a running total please help
 
Hi,
To increment A2 by 1 each time:

Range("a2").value=Range("a2").value+1

It's not clear to me what the overall logic is - Is it simply to increment
A2 every time a value is put in A1?.

HTH

"RELWOD85" wrote:


im having a bit of trouble with this coding i want to add a value of one
to a cell to keep a running total no matter what number is put into that
cell theres more info down below please could anyone help me?

Private Sub Submit_Click()
Dim x As Integer
Dim one As Integer
Dim two As Integer
Dim three As Integer
Dim four As Integer
Dim five As Integer
one = 1
two = 1
three = 1
four = 1
five = 1

x = Range("a1").Value
Range("a1").Value = Range("a2").Value
Range("a2").Value = x + ActiveCell.FormulaR1C1 = "sum(+1)"

'here instead of swopping the values each time a number one to five is
'entered i want 1 to be added so that cell a2 keeps a running total so
'if 9 was entered into cell a1 then 1 would be added to cell a2 then
if
'7 was entered into cell a1 then 1 would be addedd to the one already
in
'cell a2 making the total in that cell 2

End Sub


--
RELWOD85
------------------------------------------------------------------------
RELWOD85's Profile: http://www.excelforum.com/member.php...o&userid=25753
View this thread: http://www.excelforum.com/showthread...hreadid=392323




All times are GMT +1. The time now is 02:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com