jdellasala
Well-known Member
- Joined
- Dec 11, 2020
- Messages
- 755
- Office Version
- 365
- Platform
- Windows
- Mobile
- Web
I posted an item regarding Mr.E's Excel Formula To Extract Country From Phone Number - 2370 which I loved here today. I used a 365 formula to lookup Country Codes like this:
which references a Table of codes.
Anyway, the formula works fine, but I thought I might be able to streamline it a bit more using SEQUENCE function like this:
I get the answer, but I need to filter it to get only the item with a value. I tried this:
but obviously either FILTER won't work or I've got it wrong. Any help?
CountryCodeLookups.xlsx | ||||
---|---|---|---|---|
A | B | |||
1 | +447594361587 | United Kingdom | ||
2 | +41769482539 | Switzerland | ||
3 | +35056369249 | Gibraltar | ||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B1:B3 | B1 | =LET(Ph,SUBSTITUTE(A1,"+",""), IFNA(XLOOKUP(LEFT(Ph,6)+0,CountryCodes[Code],CountryCodes[Country]), IFNA(XLOOKUP(LEFT(Ph,5)+0,CountryCodes[Code],CountryCodes[Country]), IFNA(XLOOKUP(LEFT(Ph,4)+0,CountryCodes[Code],CountryCodes[Country]), IFNA(XLOOKUP(LEFT(Ph,3)+0,CountryCodes[Code],CountryCodes[Country]), IFNA(XLOOKUP(LEFT(Ph,2)+0,CountryCodes[Code],CountryCodes[Country]), IFNA(XLOOKUP(LEFT(Ph,2)+0,CountryCodes[Code],CountryCodes[Country]), IFNA(XLOOKUP(LEFT(Ph,1)+0,CountryCodes[Code],CountryCodes[Country]), "#ERROR!")))))))) |
Anyway, the formula works fine, but I thought I might be able to streamline it a bit more using SEQUENCE function like this:
Cell Formulas | ||
---|---|---|
Range | Formula | |
E3:E8 | E3 | =LET(Ph,SUBSTITUTE(D3,"+",""),IFNA(XLOOKUP(LEFT(Ph,SEQUENCE(6,,6,-1))+0,CountryCodes[Code],CountryCodes[Country]),"")) |
Dynamic array formulas. |
I get the answer, but I need to filter it to get only the item with a value. I tried this:
CountryCodeLookups.xlsx | ||||
---|---|---|---|---|
D | E | |||
3 | +447594361587 | #VALUE! | ||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
E3 | E3 | =LET(Ph,SUBSTITUTE(D3,"+",""),FILTER(IFNA(XLOOKUP(LEFT(Ph,SEQUENCE(6,,6,-1))+0,CountryCodes[Code],CountryCodes[Country]),""),"<>")) |
but obviously either FILTER won't work or I've got it wrong. Any help?