Forgot where I put the Select all VB code, help.

P

pgarcia

Hello all,
What is the code that will select A2:E2, shift+down arrow to last cell then
shift+up arrow?

Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlUp)).Select

But this just goes down 1 cell, I need to go to the last cell in A:E.
Thanks
 
B

Brad E.

PGarcia -

It seems you could accomplish this by selecting from A3:E3 to the end, and
then offsetting your selection by -1.
Range("A3:E3").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Offset(-1, 0).Select
 
P

pgarcia

I remmeber it being something else, but (man!) I can't remmeber where I used
it. It bugs out. It needs to shift down to the last row, in this case 65536,
then come up one. That should only pick up cells in thouse columns. Thanks,
if you know it cool if now I guess I'll keep looking.
 
B

Brad E.

PGarcia, Try this one:
Range("A2:E2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Resize(Selection.Rows.Count - 1).Select

There is a Row and Column entry for the Resize command, but by omitting the
column entry, the # of columns remains the same. To omit the row entry would
be:
Selection.Resize(, Selection.Columns.Count - 1).Select
 
Top