Solved

Excel Add to a cell

Posted on 2012-12-28
7
160 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
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!

 

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

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!

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

729 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