One of the things I am trying to do with a file is Subtract 10 days from a column A called "OUTDATE" and put the resulting date in Column J. This is how I am working it just now:
At the beginning of the sub I use this:
This gives me an "Application-defined or object-defined error" and highlights the "Range" line. HOWEVER, the dates actually do work all the way to the last row. So it's almost like it does what I want it to do but then gives up. This is the last action of many that the macro does, so the next line is End Sub.
If I change the "For i" line to For i = 2 to 60 or some other number, the macro works fine as long as there are sixty columns or more (but it only gives me dates for rows 2 to 60). But if there are less than sixty it throws an error. I really need it to find the last row.
I'd appreciate any help!
Thanks!
At the beginning of the sub I use this:
VBA Code:
lR = Cells.Find("*", Cells(1, 1), xlFormulas, xlPart, xlByRows, xlPrevious, False).Row
'and then in the section where I am subtracting the dates, I use this:
Dim i As Integer
For i = 2 To lR
Range("J" & i) = DateAdd("d", -10, Range("A" & i))
Next i
This gives me an "Application-defined or object-defined error" and highlights the "Range" line. HOWEVER, the dates actually do work all the way to the last row. So it's almost like it does what I want it to do but then gives up. This is the last action of many that the macro does, so the next line is End Sub.
If I change the "For i" line to For i = 2 to 60 or some other number, the macro works fine as long as there are sixty columns or more (but it only gives me dates for rows 2 to 60). But if there are less than sixty it throws an error. I really need it to find the last row.
I'd appreciate any help!
Thanks!