How to reverse a text string
Flip the characters in a cell end-to-end — "abc" becomes "cba" — for palindrome checks, obfuscation, or reversing codes.
The formula
| App | Formula | Notes |
|---|---|---|
| Excel | =TEXTJOIN("",TRUE,MID(A2,SEQUENCE(LEN(A2),1,LEN(A2),-1),1)) | No built-in REVERSE. SEQUENCE counts positions down from the last, MID pulls each character, TEXTJOIN glues them. Excel 365 / LibreOffice 24.8+; older Excel needs Ctrl+Shift+Enter. |
| Google Sheets | =TEXTJOIN("",TRUE,MID(A2,SEQUENCE(LEN(A2),1,LEN(A2),-1),1)) | Identical. |
| LibreOffice Calc | =TEXTJOIN("",TRUE,MID(A2,SEQUENCE(LEN(A2),1,LEN(A2),-1),1)) | Needs 24.8+ for SEQUENCE. |
How it works
None of the three apps has a REVERSE function, so the trick is to read the characters back to front and rejoin them. SEQUENCE(LEN(A2),1,LEN(A2),-1) builds the position list from the last character down to the first — for "abc" that's {3;2;1}; MID(A2, that, 1) grabs one character at each position, giving {"c";"b";"a"}; and TEXTJOIN("",TRUE,...) concatenates them into "cba". It's a spilling array formula, so it needs dynamic arrays (Excel 365, Google Sheets, LibreOffice 24.8+); on legacy Excel enter it with Ctrl+Shift+Enter and swap SEQUENCE for LEN(A2)-ROW(INDIRECT("1:"&LEN(A2)))+1. To reverse the ORDER OF ITEMS in a list rather than characters in a string, that's a different job — see reverse-the-order-of-a-list. A common use is testing for palindromes: compare A2 to its reverse with EXACT.
Functions used
TEXTJOIN · MID · SEQUENCE · LEN — see full Excel, Google Sheets & LibreOffice compatibility for each.
Related recipes
- How to extract numbers from text in a cell
- How to capitalize only the first letter (sentence case)
- How to extract the domain from an email address
- How to extract the last name from a full name
- How to remove text before a character