+ Reply to Thread
Results 1 to 4 of 4

VBA Code to archive or delete and change data

  1. #1
    Registered User
    Join Date
    08-03-2010
    Location
    puckeridge,herts
    MS-Off Ver
    Excel 2003
    Posts
    45

    VBA Code to archive or delete and change data

    Hi

    I am creating an attendance log for work, and want to see if my 2 requests can work.

    1) After 365 days has elapsed, I want the row, containing that date to either be archived or deleted. In my example attached, I have the in column B, with more data in other columns, such has someone's name, occasion etc
    2) The second part: If someone has multiple entries, can the next date (once the previous one was archived or deleted), change the occasion number accordingly, say from a 2 to a 1?

    attached is an example worksheet.

    Many thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,641

    Re: VBA Code to archive or delete and change data

    Hi there,

    Take a look at the attached workbook and see if it does what you need.

    The code used for deleting outdated records is as follows:

    Please Login or Register  to view this content.
    The highlighted values may be altered to suit your own requirements.


    Rows which contain entries older than 365 days will be automatically highlighted for deletion, and all such rows can be deleted by clicking on the "Delete Old Records" button.

    Note that the text "To Be Deleted" (as displayed on the worksheet) is specified as the value of the workbook-level Defined Name "sDELETE". This Defined Name is used in Formulas, for Conditional Formatting, and also in the VBA Code. Specifying the text value in this way means that your own preferred text (e.g. "For Deletion", "Time-Expired" etc.) can be specified as the value of the Defined Name "sDELETE", and all Formulas, Conditional Formatting etc. will remain unaffected by the change.

    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    08-03-2010
    Location
    puckeridge,herts
    MS-Off Ver
    Excel 2003
    Posts
    45

    Re: VBA Code to archive or delete and change data

    Hi Greg

    Firstly, thank you for the explanation, which I find very valuable, as it does help me learn as I go.

    Secondly, this is what I am after. I have tested it, and found it to work well. I also dropped it into my existing workbook, made some changes, and works well.

    regards

    Darren

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,641

    Re: VBA Code to archive or delete and change data

    Hi again Darren,

    Many thanks for your feedback and also for the Reputation increase - much appreciated

    You're welcome - I'm very pleased that I was able to help.

    Best regards,

    Greg M

+ 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. Macro to copy a line to archive sheet and delete from active sheet
    By mmccra2858 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-08-2015, 09:15 PM
  2. [SOLVED] combined code for multiple actions (email,copy, paste,delete, change colour)
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-25-2014, 07:59 AM
  3. code/script to connect macro to livelink archive windows imaging
    By giomckenzie12 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-30-2013, 05:50 AM
  4. Run Time error due to event change code when I delete columns in file
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-16-2012, 12:53 PM
  5. Help with VBA to auto archive data
    By Kayaness in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-05-2012, 01:43 AM
  6. change a code to delete rows
    By meslija in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-06-2011, 04:53 PM
  7. Worksheet Change code not running when you just delete data in cells.
    By KimberlyC in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-22-2005, 09:05 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