ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How To: Get Last Cell (https://www.excelbanter.com/excel-programming/283761-re-how-get-last-cell.html)

Bill Manville

How To: Get Last Cell
 
Kevin McCartney wrote:
I currently use Set rgeEnd = xlsheet.Cells.SpecialCells
(xlCellTypeLastCell) but for some reason the event
SheetSelectionChange triggers so how do I get the range of
the last cell (bottom right cell) in a sheet without using
the SpecialCells xlCellTypeLastCell.


Simpler would be to have your event handler ignore this case.
At the top of a normal module:

Public ItsMe As Boolean

In your code

ItsMe=True
Set rgeEnd = xlsheet.Cells.SpecialCells(xlCellTypeLastCell)
ItsMe=False

In your SheetSelectionChange

If ItsMe Then Exit Sub


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



All times are GMT +1. The time now is 03:27 AM.

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