Text function

DETECTLANGUAGE function

Identifies the language of a piece of text and returns its language code, such as "en", "fr" or "de".

Available in Microsoft 365 only (Windows, Mac and web; needs an internet connection)

Microsoft 365 onlyWorks in Google Sheets

Syntax

DETECTLANGUAGE(text)
ArgumentWhat it means
textRequiredThe text whose language you want to identify, or a cell containing it.

Returns: A language code as text, for example es for Spanish.

How DETECTLANGUAGE works

DETECTLANGUAGE sends the text to Microsoft's online translation service and returns a short code for the language it recognises: en for English, fr for French, de for German, es for Spanish, ja for Japanese and so on. It is designed for sorting or routing mixed-language data, such as customer reviews, support tickets or survey comments that arrive in many languages.

Because the work is done online, the function needs an internet connection and the result is calculated by a language model rather than a fixed rule. Very short or ambiguous text (a single word like Hotel or a name) can be classified differently from what you expect, so give it full sentences where possible. It pairs naturally with TRANSLATE: detect the language first, then translate only the rows that are not already in your language.

It is one of the newest Excel functions and is rolling out to Microsoft 365 subscribers; perpetual versions such as Excel 2021 or 2024 do not have it.

Examples

1Tag customer reviews by language

B2fx=DETECTLANGUAGE(A2)
AB
1Review
2Le service était excellent, merci !fr
3The parcel arrived two days late.

Result: fr

The French review is recognised and the code fr is returned. Fill down to tag every review.

2Flag rows that need translation

B2fx=IF(DETECTLANGUAGE(A2)="en","OK","Translate")
AB
1Comment
2Die Rechnung ist falsch.Translate
3Great product, fast delivery.

Result: Translate

The German comment returns de, which is not en, so the row is marked for translation.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 13 KB

Common errors and how to fix them

ErrorWhy it happensFix
#VALUE!The text is empty or cannot be analysed.Skip blanks with =IF(A2="","",DETECTLANGUAGE(A2)).
#CONNECT!Excel could not reach the online service (offline, blocked by a firewall or service limits).Check the internet connection and recalculate later.
#NAME?Your version of Excel does not have the function yet.Update Microsoft 365 or use a manual language column.

Tips

  • Results can change if the service is updated, so copy and Paste Values once you are happy with the tags.
  • There is a usage limit on online calls; avoid filling the formula down tens of thousands of rows at once.

Google Sheets

DETECTLANGUAGE also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

DETECTLANGUAGE in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
DanishREGISTRERSPROG
FinnishTUNNISTAKIELI
HungarianNYELVFELISMERÉS
PolishWYKRYJJĘZYK
RussianОПРЕДЕЛИТЬЯЗЫК
SpanishDETECTARIDIOMA
SwedishIDENTIFIERASPRÅK