+ Reply to Thread
Results 1 to 10 of 10

Keep values from source cell even if source cell is deleted

  1. #1
    Registered User
    Join Date
    09-06-2018
    Location
    Rio
    MS-Off Ver
    2016
    Posts
    24

    Keep values from source cell even if source cell is deleted

    Hi everybody.

    I´m working in a workbook to keep tracking of the changes in the clients demand dates.

    I have a initial date (from) and end date (to) and i need to store this dates when they are deleted.
    I was able to come around a way to store the values and if the source change, the cell keeps the original value and a cell next to it keeps the new date, and so on, up to 10 changes.
    I also record the date and time the change was made
    But if i delete the source, everything is lost.
    I need to figure out a way to do keep the stored values even when i delete the source.

    Example of my sheet:

    B2: source start date (from)
    C2: source end date (to)

    hidden collumns:

    D2: initial start date =IF($B2="","",IF(D2="",$B2,D2))
    E2: initial end date =IF($C2="","",IF(E2="",$C2,E2))
    F2: 1st input =IF(E2="","",IF(F2="",NOW(),F2))

    Changes:
    start date 1: =IF(D2="","",IF(D2=$B2,"",IF(G2="",$B2,G2)))
    End date 1: =IF(E2="","",IF(E2=$C2,"",IF(H2="",$C2,H2)))
    Change time 1: =IF(H2="","",IF(I2="",NOW(),I2))

    and so on up to change 10

    Does anyone have an idea?
    Attached Files Attached Files

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Keep values from source cell even if source cell is deleted

    What do you mean by i need to store this dates when they are deleted. Do you mean you select the date cell and press the Delete key? Do you mean delete the whole row? Also you mentioned that you want to keep the last 10 changes.

    I think I have something that might work. However if you write the information to a log file you can have an indefinite number of changes, and record a change time for both the From and To.

    This workbook uses a VBA change event.
    Attached Files Attached Files
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    09-06-2018
    Location
    Rio
    MS-Off Ver
    2016
    Posts
    24

    Re: Keep values from source cell even if source cell is deleted

    Thank you very much!!! Its exctaly what i needed!!
    I wanted to delete the cell and keep the values.

    Only one minor thing, when i delete the source cell, it marks as a change. Is there any way to avoid that?
    Im not a VBA expert

  4. #4
    Registered User
    Join Date
    09-06-2018
    Location
    Rio
    MS-Off Ver
    2016
    Posts
    24

    Re: Keep values from source cell even if source cell is deleted

    Quote Originally Posted by dflak View Post
    What do you mean by i need to store this dates when they are deleted. Do you mean you select the date cell and press the Delete key? Do you mean delete the whole row? Also you mentioned that you want to keep the last 10 changes.

    I think I have something that might work. However if you write the information to a log file you can have an indefinite number of changes, and record a change time for both the From and To.

    This workbook uses a VBA change event.
    If i write to a log file, can i extract later in another sheet by formula?

  5. #5
    Registered User
    Join Date
    09-06-2018
    Location
    Rio
    MS-Off Ver
    2016
    Posts
    24

    Re: Keep values from source cell even if source cell is deleted

    Another, is this VBA gonna work for every row or just 1? in the example, i have just one row, but in the real workbook i will have infinite rows, so i need record each one of them.

  6. #6
    Registered User
    Join Date
    09-06-2018
    Location
    Rio
    MS-Off Ver
    2016
    Posts
    24

    Re: Keep values from source cell even if source cell is deleted

    Quote Originally Posted by rjcarlantonio View Post
    Another, is this VBA gonna work for every row or just 1? in the example, i have just one row, but in the real workbook i will have infinite rows, so i need record each one of them.
    Never mind, i just checked and it works for the entire row

  7. #7
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Keep values from source cell even if source cell is deleted

    A couple of things:

    I can add a check so if the target is blank, it does not mark it as a change.

    I converted a range to an excel table. This means that everything copies down as you add rows. It also limits the number of cells that the code has to look at.

    If I change the code to write to a log file, then you can recover the contents with a pivot table.

    Would you like to investigate doing a log? I'll make the other fixes when I convert to this format.

  8. #8
    Registered User
    Join Date
    09-06-2018
    Location
    Rio
    MS-Off Ver
    2016
    Posts
    24

    Re: Keep values from source cell even if source cell is deleted

    Quote Originally Posted by dflak View Post
    A couple of things:

    I can add a check so if the target is blank, it does not mark it as a change.

    I converted a range to an excel table. This means that everything copies down as you add rows. It also limits the number of cells that the code has to look at.

    If I change the code to write to a log file, then you can recover the contents with a pivot table.

    Would you like to investigate doing a log? I'll make the other fixes when I convert to this format.
    If you could, it would be awesome!!!!

  9. #9
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Keep values from source cell even if source cell is deleted

    I am no longer keeping track of the changes on Sheet 1.

    As you change values in Columns B and C, the changes are recorded in the log.

    The log then drives the pivot table on the pivot sheet. The pivot sheet shows the changes as they were made by row and in the order that they were made. It displays the number of changes for the row with the most changes. In the example, this is 6 changes (one original plus 5 more). You are not limited to the number of changes you can have.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    09-06-2018
    Location
    Rio
    MS-Off Ver
    2016
    Posts
    24

    Re: Keep values from source cell even if source cell is deleted

    Man, This was a hell of job!! Amazing.
    Thank You very much, it works perfect

+ 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. Connection refresh of source data and cell values saved and looked up
    By VBANoob_Mazura in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-23-2017, 05:42 PM
  2. Combine duplicate values into single Cell with different source data
    By Yuvaraaj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-03-2016, 01:15 PM
  3. Replies: 2
    Last Post: 03-02-2015, 07:02 AM
  4. Replies: 2
    Last Post: 12-03-2014, 10:10 AM
  5. Index-Match Still Displays The Value After The Source Has Already Been Deleted
    By seimeion1208 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-25-2013, 10:07 AM
  6. macro to merge values from one column into one cell and retain source formatting.
    By Scott Taylor in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 12-05-2012, 04:41 PM
  7. Change source data of chart by adjusting two cell values
    By kadekl in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 10-19-2012, 05:54 AM

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