View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
PAS PAS is offline
external usenet poster
 
Posts: 26
Default Declare variables to a code?

Thanks guys,
I get a runtime error 1004
with the following highlighted:
Cells(R, 1).EntireRow.Delete

"Roger Govier" wrote:

Hi

I would use Longs rather than Integers

Sub Del_Oldies()
Dim LR as long, R as long
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

--
Regards
Roger Govier

Pas wrote:
I have the following code which deletes all rows older then 365 days:

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

I keep getting error message
Compile error:
Variable not defined
with "LR =" highlighted in blue

How do I modify this code to declare the variables R, and LR as Integers .

.