ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Updating the contents of a cell (https://www.excelbanter.com/excel-discussion-misc-queries/134406-updating-contents-cell.html)

ruthhicks999

Updating the contents of a cell
 
I am trying to update a cell so that it equals itself + another value.

I am thinking that I will need to use a macro but am not sure about the format of the macro.

The cell I am trying to update is called hptotal and I am trying to add the value of the cell called extrahp to it each time the value of extrahp changes.

Gary''s Student

Updating the contents of a cell
 
Private Sub Worksheet_Change(ByVal Target As Range)
Set hptotal = Range("A1")
Set extrahp = Range("A2")
If Intersect(Target, extrahp) Is Nothing Then
Exit Sub
End If
hptotal.Value = hptotal.Value + extrahp.Value
End Sub


Adjust the addresses of the two cells to meet your needs.
--
Gary''s Student
gsnu200710


"ruthhicks999" wrote:


I am trying to update a cell so that it equals itself + another value.

I am thinking that I will need to use a macro but am not sure about the
format of the macro.

The cell I am trying to update is called hptotal and I am trying to add
the value of the cell called extrahp to it each time the value of
extrahp changes.




--
ruthhicks999


Gord Dibben

Updating the contents of a cell
 
Just make sure you don't make a mistake entering data in A2.

You will never know when it was made and may not be able to recover from it.

You would be far safer entering the numbers in a helper column so's you would
have a "paper trail" to follow for troubleshooting.


Gord Dibben MS Excel MVP

On Mon, 12 Mar 2007 06:27:03 -0700, Gary''s Student
wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
Set hptotal = Range("A1")
Set extrahp = Range("A2")
If Intersect(Target, extrahp) Is Nothing Then
Exit Sub
End If
hptotal.Value = hptotal.Value + extrahp.Value
End Sub


Adjust the addresses of the two cells to meet your needs.
--
Gary''s Student
gsnu200710


"ruthhicks999" wrote:


I am trying to update a cell so that it equals itself + another value.

I am thinking that I will need to use a macro but am not sure about the
format of the macro.

The cell I am trying to update is called hptotal and I am trying to add
the value of the cell called extrahp to it each time the value of
extrahp changes.




--
ruthhicks999



ruthhicks999

Gord please can you explain what you mean by a helper column, I would like a record to be kept ideally but I am not sure how I could go about this.

Gord Dibben

Updating the contents of a cell
 
A helper column in this case is one where you enter the data and use a formula
elsewhere to gather that data.

Say you want A1 to keep a running total of numbers placed in column B...........

In A1 enter =SUM(B:B)

As you enter numbers down column B, A1 will update.

The "paper trail" is in column B.


Gord


On Wed, 14 Mar 2007 08:52:38 +0000, ruthhicks999
wrote:


Gord please can you explain what you mean by a helper column, I would
like a record to be kept ideally but I am not sure how I could go about
this.



ruthhicks999

I have been trying to get the Macro to work for a couple of weeks now without success. The main thing that puzzles me is that when I write the macro and save it, when I go back to Tools, Macros, Run it is not even shown as a macro. Through the editor I can see it but again it will not run.

How do I actually get it to run? I want to call this macro from another macro - something that I have not done before, please can you advise on how to do that too.


All times are GMT +1. The time now is 03:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com