+ Reply to Thread
Results 1 to 16 of 16

Timestamp not calculating when referencing a calculated (IF) cell

  1. #1
    Registered User
    Join Date
    01-24-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    8

    Timestamp not calculating when referencing a calculated (IF) cell

    I have read dozens of posts regarding McGimpsey solution to the timestamp problem (http://www.mcgimpsey.com/excel/timestamp.html)

    His VBA solution works perfectly if you type a value in the reference cell.

    However if the reference cell contains a formula then nothing happens.

    eg:

    Col B: =if(A1>50,1,0) etc . .
    Col C: Uses McGimpsey VBA code to update C1 when A1>50

    The Col C timestamp only works if I type "1" into Col B. Nothing happens otherwise.

    My actual problem is much more complex than shown above - but I hope this illustrates the point.

    Any ideas how to overcome this problem.
    Last edited by gregcarroll; 02-07-2012 at 05:43 PM.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Timestamp not calculating when referencing a calculated (IF) cell

    If the change is the result of a formula then take a look at the calculate event
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    01-24-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Timestamp not calculating when referencing a calculated (IF) cell

    Hi Jeff,

    Could you please elaborate so I dont have to search through a few dozen more forums. I am new to VBA in Excel.

    Greg

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Timestamp not calculating when referencing a calculated (IF) cell

    Hi Greg,

    Maybe this will help

    http://dmcritchie.mvps.org/excel/event.htm#calculate

    From Excel help
    Worksheet.Calculate Event
    Occurs after the worksheet is recalculated, for the Worksheet object.
    Syntax

    expression.Calculate

    expression A variable that represents a Worksheet object.

    Return Value
    nothing

    Example

    This example adjusts the size of columns A through F whenever the worksheet is recalculated.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-24-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Timestamp not calculating when referencing a calculated (IF) cell

    Thanks - now I understand.

    However, I am now getting Run-time Error 424 - Object Required, yet I have not used any variables in my code and it works with no errors when under Worksheet_Change

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Timestamp not calculating when referencing a calculated (IF) cell

    What code are you using?

  7. #7
    Registered User
    Join Date
    01-24-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Timestamp not calculating when referencing a calculated (IF) cell

    The code I am using is as follows:

    Please Login or Register  to view this content.
    Regards,
    Greg

  8. #8
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Timestamp not calculating when referencing a calculated (IF) cell

    Would this work for you?

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    01-24-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Timestamp not calculating when referencing a calculated (IF) cell

    Thanks Jeff,

    Your code works nicely to solve the run-time error, but the original problem remains - the timestamp will only update in response to a manual entry. Nothing happens if the entry is produced as a result of a formula.

    I have attached a test spreadsheet so you can take a look yourself.

    This appears to be one of those deceptively difficult problems to solve.

    Greg

    Timestamp_test_spreadsheet.xlsm

  10. #10
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Timestamp not calculating when referencing a calculated (IF) cell

    Here is a macro that should work as you want.
    It actually looks at the target and makes sure it is within the whole table. I think it should only looks at column A and B but this is something you could change yourself. If value of the row of the target cell and column C is 1 then the cell of that row and column D will be set to actual date.

    Please Login or Register  to view this content.
    Last edited by p24leclerc; 01-26-2012 at 10:44 PM.

  11. #11
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,318

    Re: Timestamp not calculating when referencing a calculated (IF) cell

    Sorry about that Greg I though for sure I had the Worksheet_Calcualte event.

    I'm not all that sure at how to solve this one. Let me ask the experts how they would approach this.

  12. #12
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Timestamp not calculating when referencing a calculated (IF) cell

    You'll need to store the current values of the cells off somewhere they can be "checked" against the current values in the watched range(s). So, I'm going to assume we can use column AA to watch A, AE to watch E, and AI to watch I, 26 columns to the right.

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  13. #13
    Registered User
    Join Date
    01-24-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Timestamp not calculating when referencing a calculated (IF) cell

    Awesome - you are a legend! Many thanks!

  14. #14
    Registered User
    Join Date
    01-24-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Timestamp not calculating when referencing a calculated (IF) cell

    Not quite solved.

    JBeaucaire's code does a great job of watching the code and placing the timestamps. However, every time you open excel the cells which have previously been timestamped update to today's date. Clearly this is not what was intended!

    Any ideas how to solve this little problem?

    The latest code (as used in the attached spreadsheet) is as follows:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  15. #15
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Timestamp not calculating when referencing a calculated (IF) cell

    The code as shown does not change any value in column D unless the values in column C and column E no longer match. I see no reason to think they would change. I manually set the column D values back to a few days ago, then saved and closed/opened the file multiple times and the dates did not change.

  16. #16
    Registered User
    Join Date
    01-24-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Timestamp not calculating when referencing a calculated (IF) cell

    My apologies - I had a bit of stray code floating around. You solution works perfectly!

    Thanks again for your assistance.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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