ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   early beginner, simple question about End(xlUp) (https://www.excelbanter.com/excel-programming/391648-early-beginner-simple-question-about-end-xlup.html)

wbrowse

early beginner, simple question about End(xlUp)
 
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============


Peter T

early beginner, simple question about End(xlUp)
 
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

"wbrowse" wrote in message
ups.com...
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============




wbrowse

early beginner, simple question about End(xlUp)
 
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


Barb Reinhardt

early beginner, simple question about End(xlUp)
 
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



"wbrowse" wrote:

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============




All times are GMT +1. The time now is 10:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com