Hi Bob,
The last cell is the intersection of the last used row and the last used
column. But Excel has a problem with that. When you insert
rows or columns and then delete rows or Columns Excel doesn't
fix the lastcell indication, in fact if you add more rows and delete
more rows it has moved the last cell indication even further away.
There are things you can do and should do to fix your last cell see
http://www.mvps.org/dmcritchie/excel...l.htm#makelast
But for your purpose you probably want to find out which is
the last occupied (non blank) cell in column A.
dim lastrow as long
LastRow = Cells(Cells.Rows.Count,"A").End(xlUp).Row
'or for the next available row after the lastrow
NextRow = Cells(Cells.Rows.Count,"A").End(xlUp).Row + 1
both the above will fail if there is something in the last cell possible
in a column i.e. in A65536
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages:
http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page:
http://www.mvps.org/dmcritchie/excel/search.htm
"beeawwb " wrote ..
Got some new, and hopefully better code, the problem now is, the lastrow
thing.
Set lastcell = Range("A:A").SpecialCells(xlLastCell)
LastRow = lastcell.Row
MsgBox (LastRow)