+ Reply to Thread
Results 1 to 5 of 5

Logg calculated cell values

  1. #1
    Registered User
    Join Date
    04-15-2013
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    14

    Logg calculated cell values

    Hi!

    I have a cell, that is showing a calculated value. This value changes twice a week because the data it is based on changes. I'd like a way to log what it used to be - so that I can show a % of it going up or down. I cannot use the watch window because I need to be able to calculate that old number with the new one.

    Sheet1
    Cell A1 = 100
    Cell B1 = N/A

    Sheet2
    Cell A1 = blank

    -> data changes

    Sheet1
    Cell A1 = 200
    Cell B1 = +100% (sheet1!A1/sheet2!A1) (will add some more stuff here to make it look better)

    Sheet2
    Cell A1 = 100


    Any ideas? Thanks in advance!

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,956

    Re: Logg calculated cell values

    Use Sheet1's calculate event, though we need two cells on Sheet2 - the current value will be in A2, and the historical value will be in cell A1. Copy this code, right-click Sheet1's tab, select "View Code" and paste the code into the window that appears. Then save the workbook as a macro-enabled .xlsm

    Please Login or Register  to view this content.
    You can extend this technique to store more of your data's history to, say, create a chart.
    Last edited by Bernie Deitrick; 10-10-2014 at 10:37 AM.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    04-15-2013
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Logg calculated cell values

    Quote Originally Posted by Bernie Deitrick View Post
    Use Sheet1's calculate event, though we need two cells on Sheet2 - the current value will be in A2, and the historical value will be in cell A1. Copy this code, right-click Sheet1's tab, select "View Code" and paste the code into the window that appears. Then save the workbook as a macro-enabled .xlsm

    Please Login or Register  to view this content.
    You can extend this technique to store more of your data's history to, say, create a chart.
    This worked perfectly Bernie! I do have a bunch of cells, do I stack the codes after each other (after I figure out which cells to change)?

    Private Sub Worksheet_Calculate()
    If Worksheets("Sheet2").Range("A2").Value <> Range("A1").Value Then
    Worksheets("Sheet2").Range("A1").Value = Worksheets("Sheet2").Range("A2").Value
    Worksheets("Sheet2").Range("A2").Value = Range("A1").Value
    End If
    End Sub

    Private Sub Worksheet_Calculate()
    If Worksheets("Sheet2").Range("X2").Value <> Range("X1").Value Then
    Worksheets("Sheet2").Range("X1").Value = Worksheets("Sheet2").Range("X2").Value
    Worksheets("Sheet2").Range("X2").Value = Range("X1").Value
    End If
    End Sub


    Thanks again!

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,956

    Re: Logg calculated cell values

    Just one event, with lots of If/End Ifs

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-15-2013
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Logg calculated cell values

    Quote Originally Posted by Bernie Deitrick View Post
    Just one event, with lots of If/End Ifs

    Please Login or Register  to view this content.
    RIght, OK that makes sense. I shouldn't have made an example with both A1 and B1 in both sheets though, hard to tell which is which when I'm changing the code to fit. Could you help me with the code for the actual cells? I owe you big time mate

    Sheet1
    Cell C23 = 100
    Cell C24 = N/A

    Sheet2
    Previous B2 = blank
    Current B3 = 100

    -> data changes

    Sheet1
    Cell C23 = 200
    Cell C24 = % change

    Sheet2
    Previous B2 = 100
    Current B3 = 200

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 12-14-2012, 01:17 PM
  2. Replies: 8
    Last Post: 06-15-2012, 08:43 AM
  3. logg in code
    By wahib in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-12-2009, 07:01 AM
  4. Create Chart with calculated cell values
    By JosephPraboi in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 07-30-2009, 09:49 AM
  5. [SOLVED] how to change a calculated cell to = the calculated value
    By CAM in forum Excel General
    Replies: 4
    Last Post: 01-26-2006, 01:30 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1