title: Counting instances of cargo within two ranges
body: <p>I have a list of cargo by length and weight, and I'm trying to get source data for a chart to show how the weight is distributed within each length window.</p>
  
  <p>The cargo is between 14 and 21 metres long, and lengths are to be displayed in metre classes - 14-15, 15-16 and so on.
  The weights are between 30 and 100 metric tonnes, to be illustrated in 10-tonne segments.</p>
  
  <p>I currently have quantities (to integers), lengths (to three decimals) and weights (to kg integers) in ranges called <code>Lengths</code> and <code>Weights</code>.</p>
  
  <p><a href="https://i.stack.imgur.com/dkHGt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dkHGt.png" alt="Starting data"></a></p>
  
  <p>I have the starts of the windows in columns <strong>H</strong> (Length) and <strong>J</strong> (Weight), with the count intended to appear in column <strong>K</strong> (Count). So far I've constructed this formula (this one in <strong>K2</strong>):</p>
  
  <pre><code>=COUNTIFS(Lengths, "&gt;="&amp;$H2, Lengths, "&lt;"&amp;$H2&amp;"+1", Weights, "&gt;="&amp;$J2, Weights, "&lt;"&amp;$J2&amp;"+10000")
  </code></pre>
  
  <p>Leaving the cell references inside the quotes just kept the same references all the way down, but breaking them out as above doesn't seem to have made any difference. The formula above also doesn't take quantities (in column <strong>A</strong>) into account.</p>
  
  <p>I suspect <code>SUMPRODUCT</code> would be a better way of going about it, but I just can't seem to wrap my head around it. I've looked it up in a few places, but really only managed to confuse myself...</p>
  
  <p>How can I make it give me a reliable count?</p>