ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   XP VBA: Range("A2", ActiveCell.SpecialCells(xlLastCell)).Select (https://www.excelbanter.com/excel-programming/272463-xp-vba-range-a2-activecell-specialcells-xllastcell-select.html)

wessman

XP VBA: Range("A2", ActiveCell.SpecialCells(xlLastCell)).Select
 
I can use the following to select all the "active" cells:

Range("A2", ActiveCell.SpecialCells(xlLastCell)).Select

....but why can't I use the following to select JUST the last active
cell?

Range(ActiveCell.SpecialCells(xlLastCell)).Select

....am I missing something? I'm trying to get the Row Number of the
last active cell on a sheet and pass it to the next line in the macro.

Ron de Bruin

XP VBA: Range("A2", ActiveCell.SpecialCells(xlLastCell)).Select
 
Hi wessman

Don't use SpecialCells(xlLastCell) or UsedRange.Rows.Count
It don't always give you a correct answer

You can use a function
See a example here
http://www.rondebruin.nl/copy1.htm


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"wessman" wrote in message m...
I can use the following to select all the "active" cells:

Range("A2", ActiveCell.SpecialCells(xlLastCell)).Select

...but why can't I use the following to select JUST the last active
cell?

Range(ActiveCell.SpecialCells(xlLastCell)).Select

...am I missing something? I'm trying to get the Row Number of the
last active cell on a sheet and pass it to the next line in the macro.




pancho[_8_]

XP VBA: Range("A2", ActiveCell.SpecialCells(xlLastCell)).Select
 
try:
ActiveCell.SpecialCells(xlLastCell).Select




Francisco Mariscal
fcomariscal at hotmail dot com


-----Original Message-----
I can use the following to select all the "active" cells:

Range("A2", ActiveCell.SpecialCells(xlLastCell)).Select

....but why can't I use the following to select JUST the

last active
cell?

Range(ActiveCell.SpecialCells(xlLastCell)).Sele ct

....am I missing something? I'm trying to get the Row

Number of the
last active cell on a sheet and pass it to the next line

in the macro.
.



All times are GMT +1. The time now is 04:36 PM.

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