From: מיכאל (מיקי) אבידן on
You may consider to delete the "Option Explicit" Statement otherwise you are
forced to declare all variables at that Module level.
OR:
Declare the variables R, and LR as Integers .
Check the VBE Help.
Micky


Used at module level to force explicit declaration of all variables in that
module.


--
והמשך/י, נא, לקרוא את השורה הבאה:
***********
אם תגובתי עזרה לחץ/י, נא, על <כן> בפס האופקי התחתון!
***********
מיכאל אבידן
מנהל פורום "אופיס" ב"תפוז"
[Microsoft" Most Valuable Professional [MVP"


"Pas" wrote:

> sorry i also get "LR =" highlighted in blue
>
> "מיכאל (מיקי) אבידן" wrote:
>
> > If you agree to ignore lap years then the following simple code will do.
> > Put it into the Sheet "details" Level:
> > --------------------------------
> > Sub Del_Oldies()
> > LR = Cells(Rows.Count, 1).End(xlUp).Row
> > For R = LR To 1 Step -1
> > If Date - Cells(R, 1) > 365 Then Cells(R, 1).EntireRow.Delete
> > Next
> > End Sub
> > --------------
> > Micky
> >
> >
> > "Pas" wrote:
> >
> > > How do I create a macro that will delete entire row if older then 365 days.
> > > Dates are on col "A"
> > > last col of data = "U"
> > > Data is kept in sheet "details"
> > >
> > > Thank you
From: Pas on
Sorry guys,
I'm still getting error messages with both suggestions.
How do I declare the variables R, and LR as Integers .


"ozgrid.com" wrote:

> Try;
>
>
> Sub DeleteOldDates()
> Dim lDate As Long
>
> lDate = Date - 365
> With Sheets("details")
> .AutoFilterMode = False
> .Range("A1:A2").AutoFilter Field:=1, Criteria1:="<" & lDate
> .AutoFilter.Range.Offset(1,
> 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
> .AutoFilterMode = False
> End With
>
> End Sub
>
>
>
> --
> Regards
> Dave Hawley
> www.ozgrid.com
> "Pas" <Pas(a)discussions.microsoft.com> wrote in message
> news:1A05E0D7-7EFD-45FE-9907-8E69987FB5CD(a)microsoft.com...
> > How do I create a macro that will delete entire row if older then 365
> > days.
> > Dates are on col "A"
> > last col of data = "U"
> > Data is kept in sheet "details"
> >
> > Thank you
>