Range("a21") .end(xlDown) or .end(xlUp) . offset(1,0) . value

J

JDB

Can anyone help explain this situation;

When I try this statement:

Range("a21").end(xlDown).offset(1,0).value = x the cursor does NOT find the end of the list in column "A" to place the value in the proper cell.

When I try this statement
Range("a21").end(xlUp).offset(1,0).value = x the cursor DOES find the end of the list in column "A"to place the value in the proper cell.

This puzzles me to not end.

Thanks for any enlightenment


JDB
 
G

GS

JDB wrote :
Can anyone help explain this situation;

When I try this statement:

Range("a21").end(xlDown).offset(1,0).value = x the cursor does NOT find the
end of the list in column "A" to place the value in the proper cell.

When I try this statement
Range("a21").end(xlUp).offset(1,0).value = x the cursor DOES find the end of
the list in column "A"to place the value in the proper cell.

This puzzles me to not end.

Thanks for any enlightenment


JDB

Using End basically does the same thing as using the Ctrl and Down [or
Right] arrow keys. So.., if there's any blank cells between 'A1" and
"A21" then using End(xlDown) sets the cell ref one row above the blank
cell. The correct way to find the last row in a column is to start at
the bottom (ie: Cells(ActiveSheet.Rows.Count, 1).End(xlUP), which in
your case might be "A21". Otherwise, you could get the next row by
simply using Range("A21").Offset(1) to ref cell "A22".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top