early beginner, simple question about End(xlUp)

W

wbrowse

Hi,

Does the following tells Excel or Vba to assign the lastest bottom
cell in the range A:A to BottomCell. In other words, is it a single
cell being taken in consideration or is it a range? Because for me,
from A65526 to xlUp, wherever is xlup it is a range.

Still about that entrie below, could this object be a mulitple column
range? Or the fact that "A" is mentionned in A65536 tells Vba to look
in A column only?

Set BottomCel = Range("A65536").End(xlUp)

What about this way to do it?

iEndRow = Sheets(4).Range("B2").End(xlDown).Row
Sheets(4).Range("D4:D" & iEndRow)

===========end of simple question===========

============thanks for your help============
 
P

Peter T

Still about that entrie below, could this object be a mulitple column
range? Or the fact that "A" is mentionned in A65536 tells Vba to look
in A column only?

Set BottomCel = Range("A65536").End(xlUp)

It looks in Col-A only. It's the same as manually - select A65536, press
End, up-arrow.
What about this way to do it?

iEndRow = Sheets(4).Range("B2").End(xlDown).Row

Again, same as manually - select B2, press End, down-arrow.
With your '.Row' the code returns the row number of the range returned by
'.End(xlDown)'
Sheets(4).Range("D4:D" & iEndRow)

Apart from (presumably) needing to assign the returned range to a range
variable, you might want to cater for the the possibility that iEndRow = 3
(if B3 is not empty and B3 is empty) or iEndRow = 65536 if there is no data
below B2.

===========end of simple answer ===========

Regards,
Peter T
 
W

wbrowse

Okay, i think it helps. Thanks

Just I forgot to change B2 to D4 to make iEndRow work within the same
column as the one assigned the line above.

Things should take shape if I keep writting (copying) lines of code
from different sources and make comparaisons...as a way to learn
 
B

Barb Reinhardt

Set BottomCel = Range("A65536").End(xlUp)

This goes to the bottom of column A and finds the first filled cell.
BottomCel is set to that cell

iEndRow = Sheets(4).Range("B2").End(xlDown).Row


Works on the 4th worksheet in the workbook. If you have something in
B2:B15, nothing in B16 or B17 and then something in B18, iEndRow will return
15.

HTH,
Barb Reinhardt
 

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