Skip to content

Instantly share code, notes, and snippets.

@AMMullan
Last active July 18, 2024 09:27
Show Gist options
  • Save AMMullan/98f313c60ed6e52826e5aad7c46515d5 to your computer and use it in GitHub Desktop.
Save AMMullan/98f313c60ed6e52826e5aad7c46515d5 to your computer and use it in GitHub Desktop.
Excel Formulas
# Far better alternative to VLOOKUP
# Works in both Excel and Google Sheets
# VLOOKUP is _NOT_ case-sensitive and doesn't handle situations where the return value is in a column BEFORE the lookup.
# This uses a table called Table1 with Name and Age Columns, with the lookup being in cell A1
=INDEX(Table1[Name], MATCH(TRUE, EXACT(A1, Table1[Age]), 0))
# The following does the same but it finds text ANYWHERE inside the cell, rather than an exact value.
=INDEX(Table1[Name], MATCH(TRUE, ISNUMBER(SEARCH(A1, Table1[Age])), 0))
# And this will find the last occurrence
=INDEX(Table1[Name], LOOKUP(2, 1/(ISNUMBER(SEARCH(A1, Table1[Age]))), ROW(Table1[Name])-ROW(INDEX(Table1[Name],1))+1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment