formulas for YTD Hey Bernie

  • Thread starter Thread starter Bruce
  • Start date Start date
B

Bruce

Thanks Bernie.............I was able to get this to work
in the first cell......now if it isn't to much trouble,
can you tell me how to copy it down the whole column and
will it work like copying any formula and reference the
cell adjacent to it? example if Iget it to work in a1 and
b1 can i just drag it down or copy it and it will work in
a2 and b2 etc?



-----Original Message-----
Bruce,

You can use the worksheet's change event. Copy the code below, right click
on the sheet tab, select "View code", then paste the code into the window
that appears.

Note that if you ever need to change a value - say you entered 10 and meant
to enter 11 - then you need to undo your change by entering the negative
value of your mistake, or -10 in this example.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Range("B1").Value = Range("B1").Value + Target.Value
End If
End Sub
Bruce
 
Hi Bruce
you have to change the code. Try:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("A:A")) Is Nothing Then Exit Sub
On Error GoTo CleanUp:
With Target
If .Value <> "" Then
Application.EnableEvents = False
.offset(0,1).value = .offset(0,1).value + .value
End If
End With
CleanUp:
Application.EnableEvents = True
End Sub

Frank
 
Back
Top