+ Reply to Thread
Results 1 to 8 of 8

Auto delete rows after a month passes

Hybrid View

Mystojam Auto delete rows after a... 03-12-2013, 09:00 AM
ragavan.sridar1 Re: Auto delete rows after a... 03-12-2013, 12:07 PM
Mystojam Re: Auto delete rows after a... 03-12-2013, 02:05 PM
ragavan.sridar1 Re: Auto delete rows after a... 03-12-2013, 02:26 PM
Mystojam Re: Auto delete rows after a... 03-12-2013, 03:19 PM
Mystojam Re: Auto delete rows after a... 03-13-2013, 03:14 AM
ragavan.sridar1 Re: Auto delete rows after a... 03-13-2013, 10:02 AM
Mystojam Re: Auto delete rows after a... 03-14-2013, 04:20 PM
  1. #1
    Registered User
    Join Date
    03-07-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    11

    Auto delete rows after a month passes

    Hi,

    i need to develop a macro which will be run on every first day of the month and checks for any data that has dates(Column C) that are 30 days old or more, and delete the entire row accordingly. Any idea how should i go with this?

    DeleteRowAfterAMonth_Test.xlsm
    Last edited by Mystojam; 03-13-2013 at 03:20 AM.

  2. #2
    Forum Contributor ragavan.sridar1's Avatar
    Join Date
    11-19-2012
    Location
    India
    MS-Off Ver
    Excel 2010, Excel 2003
    Posts
    208

    Re: Auto delete rows after a month passes

    Hi Mystojam,,

    Try this..

    Sub deloldata()
    
    On Error GoTo errorhandler
    
    Dim a
    a = Date - 30
    
    
    ActiveSheet.Range("A:H").AutoFilter Field:=3, Criteria1:="<=" & a
    ActiveSheet.Range("a1").CurrentRegion.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete Application.DisplayAlerts = True
    errorhandler:
    If ActiveSheet.AutoFilterMode = True Then
        Selection.AutoFilter
        Else
        End If
        
        
    
    End Sub
    Thanks!
    Raga.

    Please,mark your thread [SOLVED] if you received your answer.

    Click the little star * below, to give some Rep if you think an answer deserves it.

    I learnt so many things from these links.

  3. #3
    Registered User
    Join Date
    03-07-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Auto delete rows after a month passes

    Raga.

    Hi and thanks for your attention. i tried your code but it seems like it deletes everything, including those that are less than a month. Any idea?

  4. #4
    Forum Contributor ragavan.sridar1's Avatar
    Join Date
    11-19-2012
    Location
    India
    MS-Off Ver
    Excel 2010, Excel 2003
    Posts
    208

    Re: Auto delete rows after a month passes

    it works fine for me..

    did you tried it with the recent data..

  5. #5
    Registered User
    Join Date
    03-07-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Auto delete rows after a month passes

    Raga,

    the recent data all had dates that are more than a month old, so i change some of the dates to less than a month, but everything gets deleted too

  6. #6
    Registered User
    Join Date
    03-07-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Auto delete rows after a month passes

    Sorry, i misunderstood my task, now i need the macro to run on the 1st of every month to check for any data that are 30 days old or more and delete them accordingly. Is this possible?

  7. #7
    Forum Contributor ragavan.sridar1's Avatar
    Join Date
    11-19-2012
    Location
    India
    MS-Off Ver
    Excel 2010, Excel 2003
    Posts
    208

    Re: Auto delete rows after a month passes

    Hi Mystojam,

    Do you want the macro to automatically run on 1st of every month?

  8. #8
    Registered User
    Join Date
    03-07-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Auto delete rows after a month passes

    raga,

    Yes but i have already sorted it out myself it's done. Sorry for the late reply and thank you for your attention! Much appreciated!

    Mystojam

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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