Reputation: 67
I'm experiencing an error with using the End method of the range object.
The code below is an excerpt from my program, and when I get to the last line I get the following error: "Application defined or Object Defined error"
Sub DataGroup(testCell, j, k)
Dim archive As Range
Set dataCellsA = Worksheets("DATA").Range("B2")
Set dataCellsB = Worksheets("DATA").Range("I2")
For i = 0 To 30
Set currentLine = testCell.Offset(i, 0)
Set archive = Worksheets("ARCHIVE").Range("B4").End(x1Down)
However, in a later portion of my program I have what appears to be the same implementation, but I don't receive any errors with this portion.
Set dataCellsA = Worksheets("DATA").Range("C2")
Set dataCellsB = Worksheets("DATA").Range("J2")
Dim lastCellA As Range
Dim lastCellB As Range
Set lastCellA = dataCellsA.End(xlDown)
Set lastCellB = dataCellsB.End(xlDown)
Whats the difference between the two? I'm making sure to declare my variables as ranges, and I'm careful to use the "Set" prefex to ensure that it is an object, and not the value.
Upvotes: 0
Views: 1107
Reputation: 19077
So, here is the answer: you have x1Down
where you should have xlDown
(1 instead of l)
Upvotes: 2