Prev: hide formula in cells till data is available for calc
Next: Dropdown List That Accepts Other User Input
From: מיכאל (מיקי) אבידן on 4 Apr 2010 03:11 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 4 Apr 2010 17:13 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 >
First
|
Prev
|
Pages: 1 2 Prev: hide formula in cells till data is available for calc Next: Dropdown List That Accepts Other User Input |