I believe protonLeah has the correct explanation. The first number in parentheses is an argument to the End attribute, and indicates which direction to go to reach the end. However, the built-in constants listed by protonLeah correspond to the following integers:
xlDown=-4121
xlUp=-4162
xlToLeft=-4159
xlToRight=-4161
I am not sure why a 3 works here but my test shows that it does the same thing as xlUp. (In my opinion using 3 here is a poor coding practice.)
The second number in parentheses is a Range index. Any time you have an expression that returns a Range, you can add (row[, column]) indexing after it to refer to a specific cell within that Range. The indexing is relative to the upper left corner of the range (it is an index, not an offset), and may refer to a cell outside the range. The index (1, 1) refers to the upper left corner cell. If column is omitted it defaults to 1, so (1) also refers to the upper left corner.
Let's work our way inside out to break this down.
Rows.count is the number of rows in the worksheet. For 2007+ this will be 1,048,576.
Range("A" & Rows.count) will be A1048576. Note that this is a Range.
Range("A" & Rows.count).End(3) starts in A1048576 and moves upwards until it finds a used cell. Note that this expression returns a Range.
Range("A" & Rows.count).End(3)(2) starts with the used cell just found, treats it as (1, 1), and then returns the cell located at (2, 1), or one row below it.
For example, if there are 15 rows of data, the cell returned by the above will be A16.
Bookmarks