Range Selection
See inline comments...
Won't those .finds (with xlprevious) depend on where the activecell is?
No, I don't think so. Since I have not provided an After argument, the
search starts from the cell after the cell in the upper left corner of the
range (namely, "after" A1)... the range is all cells and, since xlPrevious
is used, the cell "after" A1 is the one in the bottom right corner of the
worksheet; hence, all searches take place from the bottom upward or right
side leftward.
And I bet you want header to be xlno.
Yep! I didn't pay enough attention to the your argument list when I included
it with my own code... since I am omitting the headers in my selection, the
"header" argument needs to be xlNo.
And if I know the layout of my data, I see nothing wrong with using the
.end(xlup) or .end(xltoleft) stuff.
The problem with that, as I see it, is that those methods need to specify
the row/column with data to the end. There is no guarantee that the last
header column will have data in it (could be a Comment column with no
entries in it), although that probably wouldn't screw up the sort. Also,
there is no guarantee that the last filled cell in Column A (or any other
column you might choose for that matter) will always contain the maximum
in-use row number. The code I suggested avoids these issues.
--
Rick (MVP - Excel)
|