View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Neil[_11_] Neil[_11_] is offline
external usenet poster
 
Posts: 43
Default Find last cell with data

Magnus,

you could try

cells(56550,1).end(xlup).row

which will give you the last row in column A

Neil
"Magnus Blomberg" wrote in message
...
Hello!

I have a problem about finding the last row in a sheet.

I am trying to use the code below to find my last row, but since the users
should edit my excel sheet before this script will be run, the last row
could be a complete different one than the row number returned:

Cells.SpecialCells(xlCellTypeLastCell).Row

A clearifying example: If the user gets 100 rows from a database. Then the
user deletes the last 20 rows, I want the code to return 80 instead of 100
which the code above does. It should not matter if the user removes the
data
from for example row 45 and row 68. It should simply return the row number
for the last row where data exists.

I can't find a simple solution to fix this. Tried to walk though all rows,
but didn't find a simple way to find if a row where empty from data.

Regards Magnus