ADD (A3+A1) IN MS EXCEL & I WANT OUTPUT IN CELL A3 HOW ?

  • Thread starter Thread starter seshuramakrishna
  • Start date Start date
S

seshuramakrishna

Dear ALL,



I want a macro for following scene...plz help any body...



I HAVE TWO VALUES IN CELL:A1 & CELL:A3

NOW I WANT ADD THE TWO VALUES IN THE SAME CELL A3 & IF I CHANGE THE VALUE IN
A1 THEN THAT VALUE TO BEE ADDED TO A3 VALUE(MEANS A3+A1) & SAME ......

HOW IT POSSIBLE PLZ GUIDE ME.

EX:

A1=6,A3=3

NOW I WANT IN A3=9

IF I CHANGED IN A1(A3 HAVING 9 ONLY) MEANS NOW A1=10

THEN A3 BECOMES 9+10 MEANS A3=19.& SAME CONTNUIOUS HOW IT POSSIBLE.....
 
Put the following event macro in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Target
Set a1 = Range("A1")
If Intersect(t, a1) Is Nothing Then Exit Sub
Application.EnableEvents = False
a1.Offset(2, 0).Value = a1.Offset(2, 0).Value + a1.Value
Application.EnableEvents = True
End Sub

as you change the value in A1, it will automatically be aded to the value in
A3.

Because it is worksheet code, it is very easy to install and automatic to use:

1. right-click the tab name near the bottom of the Excel window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you have any concerns, first try it on a trial worksheet.

If you save the workbook, the macro will be saved with it.


To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm
 
Back
Top