xlLastCell question

  • Thread starter Thread starter Rich
  • Start date Start date
R

Rich

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 ?
 
Rich said:
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).Select

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
 
Back
Top