Sum

souravt

New Member
Joined
Mar 30, 2009
Messages
3
Hi,
I have three column Buy,Sell and Profit.I just want to adds up repeatedly whenever i enter buy and sell value, and it will adds up repeatedly in Profit column.How do i do it.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Does this help - formulas in C2 and D2 copied down

<b>Sheet4</b><br /><br /><table border="1" cellspacing="0" cellpadding="0" style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; padding-left:2pt; padding-right:2pt; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:64px;" /><col style="width:64px;" /><col style="width:64px;" /><col style="width:64px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td><td >D</td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td >Buy</td><td >Sell</td><td >Profit</td><td >Tot Profit</td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td style="text-align:right; ">100</td><td style="text-align:right; ">110</td><td style="text-align:right; ">10</td><td style="text-align:right; ">10</td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td style="text-align:right; ">50</td><td style="text-align:right; ">65</td><td style="text-align:right; ">15</td><td style="text-align:right; ">25</td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td style="text-align:right; ">75</td><td style="text-align:right; ">77</td><td style="text-align:right; ">2</td><td style="text-align:right; ">27</td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b>Spreadsheet Formulas</b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Formula</td></tr><tr><td >C2</td><td >=B2-A2</td></tr><tr><td >D2</td><td >=SUM(C$2:C2)</td></tr></table></td></tr></table> <br />Excel tables to the web - Excel Jeanie Html 4
 
Upvote 0

souravt

New Member
Joined
Mar 30, 2009
Messages
3
Thanks for ur suggestion,But it did't work.what i want to do is just making a loop,suppose i have a cell A2,and another cell B2,anything i enter in cell A2 will be added in cell B2 and thus B2 will reapeatedly be added each time when i put number in A2.
Suppose i enter 20 in A2 cell B2 shows 20,then i enter 25 in A2 cell B2 shows 20+25=45....then i enter 30 in cell A2 cell B2 will show 45+30=75...and go on.Please tell me the formula for doing this loop function.
 
Upvote 0

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try this: right click the sheet tab, select View Code and paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "A2" Then
    Application.EnableEvents = False
    With Range("B2")
        .Value = .Value + Target.Value
    End With
    Application.EnableEvents = True
End If
End Sub

Now when you enter a number in A2 it will be added to B2.
 
Upvote 0

SPLUCENA

Board Regular
Joined
Feb 24, 2009
Messages
189
Hi Vog,

I have almost the same querry as souravt, but mine should be in column. I am trying to change the target by ("A:A") and the sum up column to ("B:B") but it is not working. I have a daily entry on column A that needs to added to column B. How can I make it work?


thanks,

splucena
 
Upvote 0

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Is this what you mean? Enter a value in A3 and it is added to B3, enter a value in A10 and it is added to B10? If so try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
    Application.EnableEvents = False
    With Target.Offset(, 1)
        .Value = .Value + Target.Value
    End With
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0

SPLUCENA

Board Regular
Joined
Feb 24, 2009
Messages
189
Hi Vog,

Just the way I tried it to be...but failed....Thanks! You are really amazing......

splucena
 
Upvote 0

Forum statistics

Threads
1,190,608
Messages
5,981,908
Members
439,743
Latest member
KatieO

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top