Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
we are trying to set up a spread sheet that contains two columns. One would
have current expenditures and the the second would be YTD. We want to have the YTD update when we change the current to add the current amount to the previous YTD. We only want one line for each expense 1 A B C D 2 Expense Current YTD 3 office supplies $10000 $ 10000 4 5 Printing $ 2000 $ 2000 __________________________________________________ __________________ next posting to current posting A B C D 1 Expense Current YTD 2 office supplies $5000 $ 15000 3 4 Printing $ 800 $2800 is there a way to say- =sum(B2+ D2) so that it will add the new current number to the YTD previous YTD. Does this make any sense? |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Clear out column D first and add this code
Private Sub Worksheet_Change(ByVal Target As Range) Const WS_RANGE As String = "B:B" '<== change to suit On Error GoTo ws_exit Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target .Offset(0, 2).Value = .Offset(0, 2).Value + .Value End With End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "charlie" wrote in message ... we are trying to set up a spread sheet that contains two columns. One would have current expenditures and the the second would be YTD. We want to have the YTD update when we change the current to add the current amount to the previous YTD. We only want one line for each expense 1 A B C D 2 Expense Current YTD 3 office supplies $10000 $ 10000 4 5 Printing $ 2000 $ 2000 __________________________________________________ __________________ next posting to current posting A B C D 1 Expense Current YTD 2 office supplies $5000 $ 15000 3 4 Printing $ 800 $2800 is there a way to say- =sum(B2+ D2) so that it will add the new current number to the YTD previous YTD. Does this make any sense? |
#3
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Bob's code will do what you want but just keep in mind that you have no audit
trail to keep track of what is entered and no way to recover from an error in data entry. Gord Dibben MS Excel MVP On Thu, 3 Jan 2008 21:31:12 -0000, "Bob Phillips" wrote: Clear out column D first and add this code Private Sub Worksheet_Change(ByVal Target As Range) Const WS_RANGE As String = "B:B" '<== change to suit On Error GoTo ws_exit Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target .Offset(0, 2).Value = .Offset(0, 2).Value + .Value End With End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Putting two formulars together in excel | Excel Discussion (Misc queries) | |||
Need help calculating formulars | Excel Worksheet Functions | |||
formulars | Excel Worksheet Functions | |||
need help with formulars | Excel Discussion (Misc queries) | |||
Formulars | Excel Worksheet Functions |