ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   xlLastCell question (https://www.excelbanter.com/excel-programming/283996-xllastcell-question.html)

Rich[_16_]

xlLastCell question
 
I am using Excel 97.

I tried this command in a macro.

ActiveCell.SpecialCells(xlLastCell).Select

I thought that the above command will return the last cell that
contains data. When I issued this command, it returned a cell that was
blank.

I am after the last row in the spreadsheet that contains data. Is
there a better way than the above command ?

Bill Manville

xlLastCell question
 
Rich wrote:
I tried this command in a macro.

ActiveCell.SpecialCells(xlLastCell).Select

I thought that the above command will return the last cell that
contains data. When I issued this command, it returned a cell that was
blank.


Try
ActiveSheet.UsedRange.SpecialCells(xlLastCell).Sel ect

LastCell gives the cell in the last Row that has been used and the last
Column that has been used since the worksheet was created - or since the
UsedRange method was used on the sheet.


Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup



All times are GMT +1. The time now is 02:37 AM.

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