Sum the value of A4+B4 in A4

H

harishnehru

Hello,

Please, I need help to calculate the total for example,

I have 100 in A4 and 4 in B4

I want to show the result in A4 as 104.

The values in A4 is entered manually from another workbook and the
result in A4 should change automatically taking values from B4

Can this be achieved?

Many Thanks in advance
 
B

Bob Phillips

This does so, but it does add B4 in every time A4 changes

'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "A4"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(target, Me.Range(WS_RANGE)) Is Nothing Then
With target
.value =.value + .Offset(0,1).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 Phillips

(remove nothere from email address if mailing direct)

"harishnehru" <[email protected]>
wrote in message
news:[email protected]...
 
M

MrShorty

Where the 100 in A4 is manually entered elsewhere, why not use in A4
=B4+[inputcell]

I haven't carefully looked over Bob Phillips code, but using his code
would break the link between A4 and the cell where the '100' was
entered.

Unless I'm not understanding what you're trying to do.
 
G

G

+100+B4 will work. If you need it to dynamically read "from another
workbook" so that you do not have to key the literal value, then
=+[Book1]Sheet1!$A$1+B4 will work, where [Book1] is your other workbook's
filespec, "Sheet1" is the name of the sheet in that workbook. and $A$1 is
the cell reference.
 

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