Rick and ExcelFox
It has been instructive to read your debate. However, neither position really covers the need that prompted my request recently. If I delete a set of rows from the worksheet, I would expect to see that deletion - somehow - reflected in UsedRange. Speifically, I am doing the following.
During a process I add occasional new rows to a worksheet - varying number of new rows representing Transactions, Merchants and LookUp entries.
During testing I need to be able to delete these entries so that I can re-run a test. Initially this is a manual process (which seems to work OK). I decided that I needed to have a way of doing it more easily - and at any rate, there are conceivable times when this will be necessary. SO, enter the cmdResetTransactions, cmdResetMerchants and cmdResetLookUp buttons. I used the macro record to 'copy' the code that Excel claims to use and was amazed to discover that there must be something more!
Research indicated that qualification was important (rather than active sheet, or simply a sheetname, I should qualify right up to the Application level). Tried this - still no luck. UsedRange would frequently indicate that some part of the sheet (which I had deleted,using EntireRow) still contained data. SInce my goal is to be able to re-use cells in a predictable manner, this behavior was unacceptable. That's my gripe with UsedRange - when a cell - or a row - has been deleted, it seems that sometimes, under unspecified conditions, it is still, in a sense, there.
Thanks, Rick for your UsedDataRange function - this will probably meet my needs. But I wish that MS would create real, usable documentation for their products, not the half-baked trash that they pump out.
(End rant!)
Thanks for the great work you guys are doing with this forum!
Tony




Reply With Quote
Bookmarks