title: Function to check if a range is contained in another
body: <p>I am looking to create a function that checks if a cell (Range1) is contained within Range2. The function would be:</p>
  
  <pre><code>Function IsWithin(Range1 as Range, Range2 as Range) as Boolean
  </code></pre>
  
  <p>This is meant to go in a <code>Before_DoubleClick</code> event to check that the cell clicked belongs to a range.</p>
  
  <p>Examples of expected input/output (<em>using addresses directly only to make it easier to imagine</em>):</p>
  
  <pre><code>IsWithin("A2", "A1:B3") = True
  IsWithin("B1","B1:B2") = True
  IsWithin("A3", "A4:C10") = False
  IsWithin("A3", "A3") = True
  </code></pre>
  
  <p>Off the top of my head I can think of a simple way to do this:</p>
  
  <pre><code>Function IsWithin(Range1 as Range, Range2 as Range) as Boolean
      Dim cell2 as range
  
      For each cell2 in Range2
            If cell2.address = Range1.Address then 
                 IsWithin = True
                 Exit Function 
            End if 
      Next
  
  End function
  </code></pre>
  
  <p>Now for the harder part, and the question. If I am selecting a Merged cell that protrudes inside Range2, I'd like it to count as being part of the range (even if some of the merged cell sticks out). What would I need to write to get that done?</p>
  
  <p>Example considering <code>A1:B3</code> is a merged cell (Still sending addresses instead of range objects as a way to represent it easier):</p>
  
  <pre><code>IsWithin("A1:B3", "A2:D7") = True
  </code></pre>