Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Cell 1 and Cell 2. I want to increase Cell 1 by 5 and decrease Cell 2 the same number as what I have increased in Cell 1. Is there a way to automatically do this and not changing the value of Cell 2 manually? I am using Microsoft Office Excel 2007.

share|improve this question

Can you not just do the maths and reference a cell?

So, in Cell 3 have the number 5.

In cell 1 do "current value + Cell3" In cell 2 do "current value - Cell3"

share|improve this answer
    
Example: Originally, I put 6 in Cell 1 and 8 in Cell 2. Then I decrease Cell 1 and make it 4, I want Cell 2 to automatically become 10. Is this possible? Thanks – Xhin0210 Jul 18 '12 at 7:13
    
Are you not able to put the figure into cell 3 with a - or + ? So, Cell 1 is 6 and Cell 2 is 8 and 3 is empty. Entering -3 in Cell 3 will obviously subtract 3 from both cells, and like ways for addition. – Dave Jul 18 '12 at 7:57

Add this VBA code then enter a value in column C to change A and B.

Private Sub Worksheet_Change(ByVal Target As Range)
  If (Target.Cells.Count <> 1) Then Exit Sub  ' one cell only
  If (Target = "") Then Exit Sub  ' if we pressed delete, do nothing more

  If (Target.Column = 3)  Then   ' we entered value in column C
    With Range(Target.Address).Offset(0, -2)  ' add it to A
      .Value = .Value + Target
    End With
    With Range(Target.Address).Offset(0, -1)  ' subtract it from B
      .Value = .Value - Target
    End With
    Target.ClearContents

    Exit Sub
  End If

End Sub
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .