Skip to main content

One Range within Another


Excel has sophisticated methods available for users but it is easy to misunderstand what the program designer really meant. The Intersect method could be one of these.

I first used the method a little over 20 years ago. It allowed me to post a value in named column, in respect of specific transaction (formed by a row). At that time, the real advantage of this approach the location of the column could change without my having to rewrite the code. It would continue to be posted to the correct cell for the purposes of the overall program.

My current task – one range within another - sounds very similar. Indeed, when searching the web, the Intersect method was offered as a potential solution. However, there are some crucial / fundamental differences.

I was not looking for overlapping ranges. Rather, the whole of the smaller range had to be contained within the boundaries of the larger one. It became clear that I had examine each of the boundaries of the larger range individually and compare them with the equivalent boundaries of the smaller one. Only if all four comparisons were valid could I be sure that no part smaller range stepped outside the boundary of the larger one. This led to some rather tediously long-winded code shown below.
Image of VB code

Mistakes in code development – or are they?

The expectation of the code above is that the larger and smaller ranges will be on the same worksheet, but the requirement is not actually specified. So, I considered what the implications might be if the two ranges were on different worksheets.
  • The code relies exclusively on the numerical values of the boundary positions of the larger and smaller ranges. If those boundary positions were satisfied then the function would still deliver a TRUE result. At first, this seemed a perfectly worthless truism.
  • It then occurred to me that the code was written, assuming that the smaller range was indeed smaller. However, it was also written such that the individual boundaries could be the same. Taken to its logical conclusion, all four boundaries of the so called larger and smaller ranges could be the same.

Taking these two conclusions together, we have a methodology for proving that two ranges on different worksheets are of identical size and in identical locations.


Sheet1



Sheet2

This sounds more like a silly panel game from the BBC’s ‘I’m Sorry I haven’t aClue’, but, if anyone can identify a genuine use for the function, I'd be delighted.





Comments

Popular posts from this blog

Generating the "ACBA-Mapping" Add-In

Background This Add-In is designed to map the underlying structure of an Excel worksheet. It. provides the means of reviewing the way that a worksheet operates both in terms of its layout and the relationship between blocks of formulae. The program for the Add-In can be downloaded from the link ' ACBA-Mapping '. Please read the following description of the process before attempting to activate it.  Generating 'ACBA-Mapping' The 'ACBA-Mapping' link will download the Add-In file to your personal Downloads folder. The File Explorer icon on your Task Bar, is the entry point. From your TaskBar Clicking this will open File Explorer. You want the Downloads folder - encircled in green. File Explorer normally opens to the 'Quick access' panel in the first instance. The Downloads folder is usually ordered youngest to oldest. So 'ACBA-Mapping' should be right at the top. The Downloads Folder ' ACBA-Mapping ' contains active code, which will have bee...

Big Brother at a Distance

We know that our spreadsheets should be functional and error free, but there is  a tension between how we review a spreadsheet to ensure that it is correct and the functionality of the spreadsheet itself. None of us like Big Brother breathing down our necks too closely. In What is a Cell Map?  I discussed the creation of a simplified version of a spreadsheet to aid review and error trapping. However, the map is itself a spreadsheet. If you created maps for each worksheet in your workbook, the workbook would quickly bloat and become unmanageable. The obvious answer is to post your maps somewhere else, but clearly linked to primary workbook. The ACBA-Mapping package does just that. It generates a separate Map Book to hold all the spreadsheet maps (and other analyses) associated with the parent workbook. The parent workbook has a new worksheet that maintains a summary of all the detailed analyses generated for the workbook. This new worksheet is called 'DataList_and_MappingC...

Cell Maps - Critical Comments

Cell maps are intended as tools for reviewing spreadsheets. If you spot an error or an inconsistency in the cell map this should be recorded and, if practicable, corrected. The cell mapping software provides a method for recording a reviewer's comments. All comments are linked to a specific map (or data table), The comments for a workbook under review are collated in a single worksheet. In this case, there's just one comment. The comment above refers to the area highlighted towards the bottom of the map below and are hyperlinked.to the specific area of the map through the column headed 'Map/Source Link'. The top left cell the source range provides a link back to the 'Comments. worksheet'. The yellow cells suggest that users should be entering information for collection by a formula, but which one.  At the this point I went back to the orginal worksheet and traced the dependents for some of these 'so called' user entry cells - also coloured yellow as it ...