+ Reply to Thread
Results 1 to 11 of 11

how can save previous values when the cells is formula

  1. #1
    Registered User
    Join Date
    05-07-2021
    Location
    Hongkong
    MS-Off Ver
    office 2013
    Posts
    5

    Question how can save previous values when the cells is formula

    Hello,

    i'm trying use vba to save previous value when the cells is formula.

    example:
    sheets1 range(B2:B5) have formula to link to sheets2 range(B2:b5)

    sheets2 range(B2:b5) is update by another excel files

    when update the excel files , sheet1 value is change. how can save the previous value to sheets1 range(c3:c5) and make a tag for which cells has update. thank you
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    12-14-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2007
    Posts
    439

    Re: how can save previous values when the cells is formula

    Hi,

    The solution I suggest is using a helper range to save the values of formulas. When the sheet calculates, copy the value of helper range to the previous range and then copy the values of formulas to helper range, like this.
    PHP Code: 
    Private Sub Worksheet_Calculate()
      
    Me.[C2:C5].Value Me.[D2:D5].Value
      Me
    .[D2:D5].Value Me.[B2:B5].Value
    End Sub 
    ❖ Please mark your thread is SOLVED if there has been offered a solution that works fine for you.

    ❖ If you like solutions provided by anyone, feel free to add reputation by clicking on ✶ Add Reputation bottom left of their posts.

  3. #3
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: how can save previous values when the cells is formula

    Code in Sheet2;

    In column D it will put the date and time when it was changed.

    Please Login or Register  to view this content.
    Last edited by Croweater; 05-08-2021 at 12:43 AM.

  4. #4
    Registered User
    Join Date
    05-07-2021
    Location
    Hongkong
    MS-Off Ver
    office 2013
    Posts
    5

    Re: how can save previous values when the cells is formula

    Quote Originally Posted by Croweater View Post
    Code in Sheet2;

    In column D it will put the date and time when it was changed.

    Please Login or Register  to view this content.

    i have another problem with same question

    the follow attachment have one sheet only, column (B:M).cells is formula link to other excel

    when cells.value changes. the old value paste on (O:Z)

    i trying use #3 code but is does not work on it
    Attached Files Attached Files
    Last edited by ray510; 05-08-2021 at 01:49 AM.

  5. #5
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: how can save previous values when the cells is formula

    Try;
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    05-07-2021
    Location
    Hongkong
    MS-Off Ver
    office 2013
    Posts
    5

    Re: how can save previous values when the cells is formula

    Quote Originally Posted by Croweater View Post
    Try;
    Please Login or Register  to view this content.
    it is not work

  7. #7
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: how can save previous values when the cells is formula

    OK, when someone says to me 'It doesn't work', without adding any value whatsoever, such as;

    'I got (this error) at (this line)'
    or
    'It didn't compile, it came up with (this error)'
    or
    'I copied the code into Sheet1, and it added the old values to the wrong columns'

    Or something else like that, I lose interest VERY quickly. As you are new, I'll maintain my interest for now.

    So why didn't it work?

  8. #8
    Registered User
    Join Date
    05-07-2021
    Location
    Hongkong
    MS-Off Ver
    office 2013
    Posts
    5

    Re: how can save previous values when the cells is formula

    i am sorry

    Attachment 731619


    left excel in the attachment
    i have copied the code into sheet1 and cells b2 is link to the right excel cells b2

    right excel in the attachment
    i have try to change the number of cells b2, left excel cells b2 number has change but the old value cannot show on cells o2

    should i add any code for link to other excel?
    Last edited by ray510; 05-08-2021 at 04:24 AM.

  9. #9
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: how can save previous values when the cells is formula

    Maybe try making a copy of the cells (helper range) after a calculation? (exacty the same idea as already suggested in post#2 for your earlier example)
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    05-07-2021
    Location
    Hongkong
    MS-Off Ver
    office 2013
    Posts
    5
    Quote Originally Posted by Croweater View Post
    Maybe try making a copy of the cells (helper range) after a calculation? (exacty the same idea as already suggested in post#2 for your earlier example)
    Please Login or Register  to view this content.
    It's work. And I try this calculating when workbook is open, it take a long time to run. Maybe have much row should Calculate in one sheet.

    Thank you for help me to solve the problem

  11. #11
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: how can save previous values when the cells is formula

    You're welcome.

+ 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. Incrementing numbers based on previous values and text values of a previous cell
    By mauricewsylvester in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-08-2021, 12:34 PM
  2. Replies: 17
    Last Post: 06-27-2014, 04:25 PM
  3. Save a Permanent Record of Previous values
    By marvslater in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-11-2013, 02:46 PM
  4. [SOLVED] How to save previous values
    By 2sqrd in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 07-09-2012, 05:35 PM
  5. Replies: 0
    Last Post: 10-14-2011, 12:09 PM
  6. Replies: 6
    Last Post: 02-28-2008, 02:46 PM
  7. need to include values of previous & present cells
    By PKMAULL in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-18-2005, 04:04 PM

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