#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 271
Default total formula

example, cell b4 contains 3. How can I get cell c4 to display b4 contents and
only add to total when b4 changes. Total being displayed in c4.

entered 3 in b4 for units ordered yesterday
entered 2 in b4 for units ordered today

want total to equal 5 but only want to enter orders daily, if this makes
sense.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default total formula

You need an accumulator. Enter the following event macro in the worksheet
code area:

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

Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200909


"shawn" wrote:

example, cell b4 contains 3. How can I get cell c4 to display b4 contents and
only add to total when b4 changes. Total being displayed in c4.

entered 3 in b4 for units ordered yesterday
entered 2 in b4 for units ordered today

want total to equal 5 but only want to enter orders daily, if this makes
sense.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default total formula

You could use this worksheet_change macro. Macro checks a time stamp (placed
in D4, change if you need to) and if total has not been updated today, then
updates total in C4.

To place macro, right click on sheet tab, view code, paste this in:

'=============
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("B4")) Is Nothing Or _
Target.Count 1 Then Exit Sub

'Check time stamp
'if data already entered today, do nothing
If Range("D4") = Date Then Exit Sub

'Add values
Range("C4") = Range("C4").Value + Range("B4").Value
'Update time stamp
Range("D4").Value = Date

End Sub
'=============
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"shawn" wrote:

example, cell b4 contains 3. How can I get cell c4 to display b4 contents and
only add to total when b4 changes. Total being displayed in c4.

entered 3 in b4 for units ordered yesterday
entered 2 in b4 for units ordered today

want total to equal 5 but only want to enter orders daily, if this makes
sense.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default total formula

You have been shown by others how to use event code to create an
accumulator.

Be aware that this type of operation allows no paper trail for error
checking when incorrect data is entered.

I say "when" not "if"


Gord Dibben MS Excel MVP



On Mon, 30 Nov 2009 11:47:01 -0800, shawn
wrote:

example, cell b4 contains 3. How can I get cell c4 to display b4 contents and
only add to total when b4 changes. Total being displayed in c4.

entered 3 in b4 for units ordered yesterday
entered 2 in b4 for units ordered today

want total to equal 5 but only want to enter orders daily, if this makes
sense.


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
A total Formula (Help) Tia[_3_] Excel Worksheet Functions 2 April 17th 08 01:20 PM
why does a formula not total right? Kickstart New Users to Excel 2 April 11th 06 01:59 PM
Old Lotus Sub Total & Grand Total formula Kylie Excel Discussion (Misc queries) 2 April 9th 06 12:24 PM
XL formula - total of row = total of column topaz Excel Worksheet Functions 2 March 17th 05 10:04 PM
Total formula Rebecca Excel Worksheet Functions 1 March 2nd 05 03:19 PM


All times are GMT +1. The time now is 06:58 PM.

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"