0

I have cell A and cell B. Both the cells contain some numeric value, say 2.

Now if i put 3 in cell A, cell B value should automatically update to 5 and so on.

Again, if i put 5 in cell A, cell B value should be 10.

Hope i have made myself clear...

Any help would be really appreciated.

Thanks Rakesh

2
  • 2
    You mean when cell A is modified cell B should update itself to add the new value of cell A to its (cell B's) existing value? What happens if the user hits 'recalculate' - nothing? I'm not sure Excel can support stateful formulas like this, but maybe with a macro. Commented Oct 18, 2013 at 13:18
  • 1
    You can do it with a macro - but it honestly doesn't sound like a good idea. Can you rather explain why you want to do this? What's your end goal? Commented Oct 18, 2013 at 13:19

1 Answer 1

2

This will work for cells A1 and B1. Put the following event macro in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Range("A1"), Target) Is Nothing Then Exit Sub
    Application.EnableEvents = False
        [B1] = [B1] + [A1]
    Application.EnableEvents = True
End Sub

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. If you are using a version of Excel later then 2003, you must save the file as .xlsm rather than .xlsx

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

and

http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx

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

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

Macros must be enabled for this to work!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.