1

I looking for help to optimize the code for a Name database I created in Google Sheets. I'm not a programmer and I have made this by researching on Youtube, Stack Overflow and other sites.

The data sheets now work as intended, but the code is way too long and it takes time for the sheet to load up and gets laggy sometimes. The database is basically a tag filter system where is excludes any name that doesn't include all the tags selected.

This is the link to the Google Sheet:

https://docs.google.com/spreadsheets/d/1g1GjgVzABXHDOsxCQS3x9F3lgeIjyxnZggbDcZj04AM/edit?usp=sharing

The code I need to optimize is in the "Search" tab in W3, X3, Y3, Z3, AA3. Thanks!

It's been a while since I have seen the code so I don't remember well. There was a function(s) I tried that would compact all the cells from a selected range, instead of writing each cell like in my code, but it did not work.

0

1 Answer 1

2

Use filter() and regexmatch(), like this:

=lambda( 
  regex, 
  iferror( 
    filter( 
      'Master Data'!A3:F, 
      regexmatch( 
        'Master Data'!AX3:AX, 
        regex 
      ) 
    ), 
    "(no matching data)" 
  ) 
)( 
  textjoin( 
    "\b.*?\b", true, 
    sort( 
      flatten( 
        bycol( 
          sequence(1, columns(H2:U2) / 2, 0, 2), 
          lambda( 
            colOffset, 
            iferror( 
              filter( 
                offset(I3:I, 0, colOffset), 
                offset(H3:H, 0, colOffset) 
              ) 
            ) 
          ) 
        ) 
      ) 
    ) 
  ) 
)

Put the formula in cell Search Tab!W3. It will fill columns W:AB automatically.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.