 <p>In Excel, you can do it using an array formula to search for the next frequency which is in range:-</p> <pre><code>=MATCH(1,(B2:B$10&gt;=49)*(B2:B$10&lt;=51),0)-1 </code></pre> <p>if your frequencies start in B2.</p> <p>Must be entered in C2 with <kbd>Ctrl</kbd><kbd>Shift</kbd><kbd>Enter</kbd></p> <p>Here is a modified version which allows for the case where the last frequency is out of range, assuming there are no blanks between frequency values and one or more blanks at the end:-</p> <pre><code>=MATCH(1,(B2:B$10&gt;=49)*(B2:B$10&lt;=51)+(B2:B$10=""),0)-1 </code></pre> <p><a href="https://i.stack.imgur.com/7SXYe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7SXYe.png" alt="enter image description here"></a></p>