Visual Basic for Applications/Excel Sheet True Used Range

Summary

 * This code listing is for Excel.  The procedure GetUsedRange returns the true used range of the Worksheet in the function name.  An example is also given below of its use in the procedure WorkRangeInArray.   It can typically be used to find the next writing position on a worksheet, but in any case returns all of the cell limits on each run.
 * Reports on various internet sites describe problems with the built-in UsedRange function.  The problem types, apart from errors of understanding, seem to be divided between issues concerning the number of cells scrolled and errors in reporting the used range itself.    This author has been unable to reproduce errors in reporting the UsedRange but requests inputs from interested parties.   Readers with a clear demonstration of the UsedRange problem might care to advise me of it in the Discussion tab of this page. It is true to say that the removal of cell content at the end of a worksheet will not result in a revised scrolled region, and the use of Ctrl-End will still travel to the old position after deletion.   These two matters are not necessarily linked however, since this still happens even while the UsedRange is correctly reported.      In the meantime this code module will obtain a true used range.
 * The procedure GetUsedRange approaches the used cells from the outer limits in all four directions, and then, after noting the first filled cells that it encounters for each direction, defines the overall range as the smallest bounding rectangle that fits the whole thing.  It optionally returns the row and column bounds at the same time.
 * The procedure WorkRangeInArray makes use of GetUsedRange in an example that loads a source sheet range onto an array for work, then passes it back to a target sheet, same or other, at some specified or default position.

VBA Code Listing (Modified 3 Dec 2016)
Added descriptive variable names for GetUsedRange parameters in accordance with suggestion in Discussion.(3 Dec 2016)