View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Keith R[_2_] Keith R[_2_] is offline
external usenet poster
 
Posts: 37
Default Locating end of used range- not returning expected value (additional info)

I was testing some new code, and identified that the LastRow procedure is
accurately identifying the last used row /only/ for the last column in my
dataset (Column U, where I just added code to add the date the record was
appended from my userform). All of the old records (rows 3-77) have
guaranteed data in columns A and B, more than half have data in C, and then
data is sporadic in G through S. Cells in G through S that have data also
automatically have comments on those cells.

Any advice or suggestions still welcome and appreciated!
Keith


"Keith R" wrote in message
...

I have code used to append new records (rows) on sheet 4. In the past, I
use the lastrow procedure (below, from this newsgroup) to find the last
row where I can add new data. however, in this particular case, it keeps
trying to add my data near the top of the worksheet. So I used the
rows.count to start troubleshooting, and got the correct value there even
though the lastrow procedure is still at the top of the sheet. I have
saved, closed, and re-opened the workbook, to no avail.

Any ideas why these two would return different values?

Thanks,
Keith
XP/XL2003

(misc code deleted)

My_LastRow = Sheet4.Cells.Find(What:="*", After:=[A1],
SearchDirection:=xlPrevious).Row
MsgBox Sheet4.UsedRange.Rows.Count
'returns a value of 77, which is accurate
MsgBox My_LastRow
'returns a value of 2, then after adding a record it returns a
value of 3.