View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
David Turner David Turner is offline
external usenet poster
 
Posts: 50
Default Very basic macro question.

Fn0rd wrote

Here's what I want to do: just for the purposes of this example, let's
say that I've got two columns, A and B. A1-A5 are numbers that change
daily, and B1-B5 are a running monthly total. I'll need to fill out the
A column myself, but I'd like to bind a key to a macro that will add
the new values from column A to the existing values in column B and
then display the results in column B. Simple, huh? So help me out!
Thanks. :)


Right-click on the desired sheet's tab, click View Code and paste this:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrHandler
If Target.Count 1 Then Exit Sub
If Intersect(Target, Range("A1:A5")) Is Nothing Then Exit Sub
If IsNumeric(Target.Value) Then
Application.EnableEvents = False
Target.Offset(0, 1).Value = Target.Value + Target.Offset(0, 1).Value
End If
ErrHandler:
Application.EnableEvents = True
End Sub


--
David