I'm trying to pull a list of people based on their last names. The catch is I only want to QUERY people with last names that fit between an alpha range to the 4th character.


I only want names that fall between Mimz and Sand

I have this formula, but it doesn't go to the 4th character and I don't understand how to update.

=QUERY(data!B1:J30000, "Select B, C, D, E, F, G, H, I, J  where lower(D) matches 
'^(m[k-z]|[n-r]|sa).*' order by D")

I believe the adjustment needs to be made here (m[k-z]|[n-r]|sa) but I don't know the syntax.

Any help is greatly appreciated.

Link to copy of report tab


Link to copy of data tab (simplified)


  • 1
    Please provide some sample data to test your formula and those to be proposed. – Rubén Nov 1 '16 at 23:39
  • @Rubén I've added the links to the question. Thanks for looking into this! – Mr. B Nov 2 '16 at 2:14
  • 1
    The spreadsheet looks very complex. Please make a simpler demo spreadsheet. – Rubén Nov 2 '16 at 4:46
  • @Rubén I've updated link to the "data" sheet and simplified it. I've also removed all other tabs that aren't directly related to this question. Thanks again! – Mr. B Nov 2 '16 at 15:13

Since this is more a regular expression logic update, I can contribute:



Just keep in mind that the range above needs to differ by the first character. If not, then pull the common characters out. For mimz-mitz:


Not saying there isn't an easier way -- this just helps you update this particular way in the future.

| improve this answer | |
  • I'm testing this now. Thank you! Is there an easier (more straight forward) way that you recommend? – Mr. B Nov 2 '16 at 16:04
  • 1
    First, I don't know how 'dynamic' it needs to be -- this regex is obviously hardcoded. Second, I don't know excel or its myriad of functions. So even if this works (and it should ;) ), someone else might come up with a better answer. That's all I meant. So short answer -- I don't know ;) – Gerard ONeill Nov 2 '16 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.