Closed Thread
Results 1 to 10 of 10

Auto delete info of a cell after 24 hours

  1. #1
    Registered User
    Join Date
    12-28-2018
    Location
    Colombia
    MS-Off Ver
    Microsoft Office 2013
    Posts
    27

    Question Auto delete info of a cell after 24 hours

    Hello dear people,

    I hope you can help me once again with a requirement I have, you usually save my life

    I was wonder if it's possible that an Excel sheet delete the info each 24 hours of certain cells that I previously indicate. I'll attach and image on this post, so that you understand me better

    Example.jpg

    I have some information in the cells of the A column, I need to use this information daily but due to the type of work I can't re-use the same information before 24 hours have elapsed. After 24 hours I can use the information again. This is just an example of 10 row but really I have a lot of rows with information.

    it occurred to me to create a button in this case the "Button 1", which I use to write the Date and the exact hour when I finish to use the information of each cell of Column A. I assigned a VERY SIMPLE macro to the Button which is:
    Please Login or Register  to view this content.
    When I'm in any cell of B column and I click this button, the actual time and the hour is written. It's worth emphasizing that all the cells in the B column have the following format d/mm/yy hh:mm as you can appreciate in the image. Having this on the next day I already have the hour where I used each information.


    What is not profitable is that I need to clean the cells of the B column in the next day and closely check each hour because the information isn't used in order and the hours are not in consecutive form like in the image of the example.

    It will good for me if the in the column B I would've an asterisk or any other sign, no matter what, that I put there when I finished use the information of that row and then sign disappears automatically after 24 hours, I supposed it could be something sync with the system clock, I don't know.

    I hope you can help me with this, excuse me if I need help with very hard things, but I trust in the great abilities of all of you

    Thank you so much!

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Auto delete info of a cell after 24 hours

    Not 100% sure what you're looking to do from your description. However, if you want to know whether the cells in column B are less than 24 hours old then:

    1. Highlight B1:B10
    2. Click Conditional Formatting > New Rule ...
    3. Select "Use a formula to determine which cells to format"
    4. In the formula box enter: =$B1>=NOW()-1
    5. Click the "Format..." button and choose a format e.g. fill the cell with orange
    6. Click all the OK buttons to apply the changes

    Does that help?

    WBD
    Office 365 on Windows 11, looking for rep!

  3. #3
    Registered User
    Join Date
    12-28-2018
    Location
    Colombia
    MS-Off Ver
    Microsoft Office 2013
    Posts
    27

    Re: Auto delete info of a cell after 24 hours

    Hello, thanks for your help! I think that maybe I was not clear enough on my requirement. I'll try to use words.

    I need to modify a cell and after 24 hours the cell auto-clear all the content I put there. For example, if I write the word "Used" in a cell, starts to count 24 hours and after it, the cell comes clear. I think is so weird and I don't know if it's possible. Maybe could be possible with the internal clock of the system, I don't know.

    I hope you can help me to find a solution

  4. #4
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Auto delete info of a cell after 24 hours

    OK. It's quite complex but I think I might have a potential solution. See the attached workbook. What I've done is this:

    1. Written all code into the ThisWorkbook module
    2. Made a list of sheets where we should implement this functionality (AuditSheets) - the names should be separated by "|" at the top of the module e.g. "|Sheet1|Sheet2|"
    3. Recorded which cells should implement this functionality (AuditRange)
    4. Specified a lifespan (in days) for the cell to be alive - this is the LifeSpan constant
    5. When a value on a tracked sheet in the tracked range is changed, write the current date and time onto a new, hidden sheet
    6. Run a check every minute to see if any values have exceeded the lifespan and, if so, clear the contents of the cell

    If you want to test it out and don't want to wait 24 hours then you have two choices:

    1. Unhide the "..|Audit" sheet and manually edit the date and time of the last cell change
    2. Change the LifeSpan constant to something that represents a much smaller period of time e.g. 0.04 is less than an hour, 0.003 is less than 5 minutes

    WBD
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    12-28-2018
    Location
    Colombia
    MS-Off Ver
    Microsoft Office 2013
    Posts
    27

    Re: Auto delete info of a cell after 24 hours

    Wow! Wow! Wow! ...... I don't have words! You make me believe that all is possible in this world of macros! I already tested it and it works perfectly. I just changed the LifeSpan to 0.003 and then I wrote and asterisk * in the Cell A1 of the Sheet1 and after 5 minutes it dissapear! just like I wanted!....wow! i'ts just awesome.

    I have some questions, I hope you can help me..

    1. What's rol of the "..|Audit" sheet? I'm asking this because I need to transfer this code to excel workbook I already have created, which is the workbook where I need to have this code working. How I can transfer the Audit sheet or how I need to create this this in this old woorkbook?

    2. Does the number 1 in the LifeSpan represents exactly ONE DAY (24 hours)?

    3. What's happen If I save the file, close it and turn off the PC? I supposed when I open the worksheet in the next day, the code will auto make the inspection in the exact moment it opens and will clear the cells normally?

    Thank you so much for your help!

  6. #6
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Auto delete info of a cell after 24 hours

    1. The Audit sheet will be created automatically in the code if it's not already there. Just make sure that you list the sheets and ranges you want to track at the top of the macro.
    2. Yes; LifeSpan is in days so 1 = 24 hours.
    3. Saving the file is fine; when you open it again, any cells that need to be cleaned will get processed.

    WBD

  7. #7
    Registered User
    Join Date
    12-28-2018
    Location
    Colombia
    MS-Off Ver
    Microsoft Office 2013
    Posts
    27

    Re: Auto delete info of a cell after 24 hours

    This was the PERFECT SOLUTION! For my requirement! Of course I'll give you a reputation Thank you so much for your help!

  8. #8
    Registered User
    Join Date
    04-13-2020
    Location
    USA
    MS-Off Ver
    2013
    Posts
    3

    Re: Auto delete info of a cell after 24 hours

    Hi there, I stumbled upon this thread, for a wonderful script and this is what I am looking for!
    Although I have a little question, instead of deleting the value of the cell over 24 hours, would it be possible to delete the entire row, and the next row moving up replacing the deleted row?

    I have a sensor that is feeding data every 5 minutes into the spreadsheet, and I'd like to keep the row count below 500, so it would be nice if the data keep moving up within 24 hours period.

  9. #9
    Registered User
    Join Date
    08-25-2021
    Location
    Czech Republic
    MS-Off Ver
    365
    Posts
    1

    Re: Auto delete info of a cell after 24 hours

    Hello, thank you very much for this excel sheet it is very helpful. But I have one question to that. Do you think I would be possible the cells would errase only its values but not the functions and formulas leading into the cells? Thank you very much for the answer.

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,800

    Re: Auto delete info of a cell after 24 hours

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Auto Logging Cell Info
    By REDPOOL in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-01-2017, 03:12 PM
  2. [SOLVED] Delete info in cell
    By mlint in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-19-2015, 04:10 AM
  3. Split and delete info in one cell?
    By LuckyMan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-25-2013, 03:48 PM
  4. Auto fill Info into a cell
    By esupply in forum Excel General
    Replies: 2
    Last Post: 11-23-2009, 02:33 PM
  5. delete cell value after 24 hours
    By hdrury in forum Excel General
    Replies: 1
    Last Post: 04-16-2009, 03:16 PM
  6. If A1 is not blank, then delete info in cell B1. How?
    By starrjohnson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-05-2008, 03:50 PM
  7. Auto enter info in a cell
    By sodaboy in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 11-02-2006, 09:58 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