Excel - Finding the Last Row, Column or Cell

This is sample code. Add error handling and adjust to your requirements as necessary.

#DEFINE xlA1       1	
#DEFINE xlR1C1     -4150	
#DEFINE xlLastCell 11
 
* Last Row/Column
lnLastRow = oSheet.UsedRange.Rows.Count
lnLastCol = oSheet.UsedRange.Columns.Count
 
* Last Cell - Intersection of the last row and the last column
lcLastCell = oSheet.Cells.SpecialCells(xlLastCell).Address(,,xlR1C1)
Your rating: None Average: 4 (1 vote)

Useful Tips

Thanks for posting useful tips.