Solved

Excel Add to a cell

Posted on 2012-12-28
7
159 Views
Last Modified: 2012-12-28
Cell A2 holds a value of $100.  Cell A1 is a cell used when an expense is made.  So, say we spent $10.  I want to enter $10 in cell A1 and have cell A2 automatially update to $110.  Or, i'd just like to be able to type over the $100 in cell A2 with $10 and have it know to add $100  + $10 to give me $110.
0
Comment
Question by:jnikodym
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38726998
If you do not change the locations described above then you can try this macro

Right-click on the sheet tab name
Select View code
Paste this code in the VBA window
Close the VBA window

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("A1").Address Then [a2] = [a1] + [a2]
End Sub

Open in new window

0
 

Author Comment

by:jnikodym
ID: 38727039
That seemed to work.  Is there a way then to clear cell A1?
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38727058
Just select A1 and press the Del key or the Delete key
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jnikodym
ID: 38727066
I know that, but i was looking for a way for the code to do that.
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38727106
Try this....is this what you mean?
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("A1").Address Then
Application.EnableEvents = False
[a2] = [a1] + [a2]
Range("A1").ClearContents
Application.EnableEvents = True
End If
End Sub

Open in new window

0
 

Author Comment

by:jnikodym
ID: 38727425
yes, but one more thing. Below is my code i'd like this code to work for the cells below as well.  For example, i'd like D11 = B11 + D11

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("B10").Address Then
Application.EnableEvents = False
[D10] = [B10] + [D10]
Range("B10").ClearContents
Application.EnableEvents = True
End If
End Sub
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 38727503
You should present all your requirements to start with instead of putting a new one every time you get a solution.

Try this...not tested

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.column =2 and target.row >9 Then
Application.EnableEvents = False
target.offset(0,2) = target + target.offset(0,2)
target.ClearContents
Application.EnableEvents = True
End If
End Sub
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question