Solved

Excel Add to a cell

Posted on 2012-12-28
7
154 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
  • 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
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…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

747 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now