Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Last used row problem

Through the valuable contributions of the MVPs and other members of this
group, I've learned a lot over the years- so thank you to everyone for your
ongoing participation and assistance.

One thing I picked up here was the following code to find the last used row:

LastRow = Sheet1.Cells.Find(What:="*", After:=[A1],
SearchDirection:=xlPrevious).Row

This has worked for me for quite some time, but now I've run into a
situation where it returns a higher row number than desired- in this case,
the users of the workbook can manually delete (with the delete key, which
actually just clears) rows, and the code above (again, some of the time) is
returning a much later row than the last row that actually has any text in
it. Conclusion- Excel requires some event or action to really think those
rows are "clear".

Other than recursively checking each cell in each row, is there something I
can do to either (a) return the last blank row, or (b) force excel to clear
any blank rows, so I get the desired row number?

Thanks,
Keith



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Last used row problem

There is information on this page Keith
http://www.rondebruin.nl/last.htm

Note: if there is a space in a cell Excel will see this

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Keith R" wrote in message ...
Through the valuable contributions of the MVPs and other members of this
group, I've learned a lot over the years- so thank you to everyone for your
ongoing participation and assistance.

One thing I picked up here was the following code to find the last used row:

LastRow = Sheet1.Cells.Find(What:="*", After:=[A1],
SearchDirection:=xlPrevious).Row

This has worked for me for quite some time, but now I've run into a
situation where it returns a higher row number than desired- in this case,
the users of the workbook can manually delete (with the delete key, which
actually just clears) rows, and the code above (again, some of the time) is
returning a much later row than the last row that actually has any text in
it. Conclusion- Excel requires some event or action to really think those
rows are "clear".

Other than recursively checking each cell in each row, is there something I
can do to either (a) return the last blank row, or (b) force excel to clear
any blank rows, so I get the desired row number?

Thanks,
Keith



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Colon at the end of excel file name(ex: problem.xls:1, problem.xls financeguy New Users to Excel 2 January 15th 10 01:15 AM
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
problem with a conditional max problem Brian Cornejo Excel Discussion (Misc queries) 1 February 18th 05 06:25 PM
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? OCI Excel Programming 0 May 16th 04 10:40 PM


All times are GMT +1. The time now is 07:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"