Help with calling an Excel program in a Excel cell

C

chichi

I wrote a function to sum up numbers I entered in Excel cell "A1" .
The program continuously sums up the numbers and clears cell "A1".
Cell "B1" is to store this summation .
I tried making the formular of cell "B1" to be the result of this
function that is making cell "B1" call this function.
See below :
Function SUMMM(A1)
Private SUM_UP
SUM_UP = A1 + SUM_UP
SUMMM(A1) = SUM_UP
Range ("A1").value = ""
End Function
I made the formular of cell "B1" to be : = SUMMM(A1) . It is giving
error message :#name
 
M

Mike H

You could try this alternative.

Right click your sheet tab, view code and paste this in

Dim TargetVal
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
If TargetVal <> Target Then
Target.Offset(1, 0).Value = Target.Offset(1, 0).Value + Target
End If
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
TargetVal = Target
End If
End Sub

Mike
 
M

Mike H

Hi,

I should have trapped for non numeric entry, try this instead

Dim TargetVal
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
If TargetVal <> Target And IsNumeric(Target) Then
Target.Offset(1, 0).Value = Target.Offset(1, 0).Value + Target
End If
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
TargetVal = Target
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top