A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Cell calculate only once



 
 
Thread Tools Display Modes
  #1  
Old May 26th, 2006, 06:31 PM posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: n/a
Default Cell calculate only once

How can I have a cell calculate only once?
Example:
Equation in cell D7 "=A1+B1"
So if I create this equation in cell D7 yesterday and A1 and B1 both equal
"1" at that time D7 will display a "2".
So today I change cell A1 to a "3". I don't want D7 to change to a "4". I
want to copy the equation in D7 to Cell D8 and I want D8 to show a value of 4
and for D7 to not update so it always shows a value of 2.
So basically the equation only calculates once, when it was created. So
cells D7, D8,.... are giving me a history of the sum of the values from A1
and B1 as they change day to day.
Thanks for the help
Adam
  #2  
Old May 26th, 2006, 07:41 PM posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: n/a
Default Cell calculate only once

Adam,

Don't use formulas: Use an event procedure to put the value of interest into an appropriate cell.

Copy the macro below, right click on the sheet tab, select "View Code", and paste the code into the
window that appears. When you change either A1 or B1, the new sum will appear in column D at the
bottom, with a date next to it (for record-keeping purposes).

HTH,
Bernie
MS Excel MVP


Private Sub Worksheet_Change(ByVal Target As Range)
Dim myC As Range

If Target.Cells.Count 1 Then Exit Sub

If Not Intersect(Range("A1:B1"), Target) Is Nothing Then
Application.EnableEvents = False
Set myC = Cells(Rows.Count, 4).End(xlUp)(2)
myC.Value = Range("A1").Value + Range("B1").Value
With myC(1, 2)
.Value = Date
.NumberFormat = "mmm dd, yyyy"
.EntireColumn.AutoFit
End With

Application.EnableEvents = True
End If
End Sub

"adamb" wrote in message
news
How can I have a cell calculate only once?
Example:
Equation in cell D7 "=A1+B1"
So if I create this equation in cell D7 yesterday and A1 and B1 both equal
"1" at that time D7 will display a "2".
So today I change cell A1 to a "3". I don't want D7 to change to a "4". I
want to copy the equation in D7 to Cell D8 and I want D8 to show a value of 4
and for D7 to not update so it always shows a value of 2.
So basically the equation only calculates once, when it was created. So
cells D7, D8,.... are giving me a history of the sum of the values from A1
and B1 as they change day to day.
Thanks for the help
Adam


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with this conditional IF statement C-Dawg General Discussion 3 May 15th, 2006 06:01 PM
GET.CELL Biff Worksheet Functions 2 November 24th, 2004 07:16 PM
In excel, the formula of a cell * by 5 then - 15 won't calculate . mrsmers General Discussion 5 October 24th, 2004 10:39 PM
IF E3 & E10 = TRUE set this cell to "Yes", else set to "No" Timothy L Worksheet Functions 5 August 27th, 2004 02:28 AM
Convert a Cell Reference to Text Chuck Buker Worksheet Functions 6 September 22nd, 2003 05:04 PM


All times are GMT +1. The time now is 07:20 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.