Any Excel function that will reverse a string?
The current accepted answer is a poor way to reverse a string, especially when there is one built into VBA, use the following code instead (should act the same but run a LOT faster):
Function Reverse(str As String) As String
Reverse = StrReverse(Trim(str))
End Function
There is no built-in function that I know of, but you can create your own custom function.
First - create a new module:
- Get into VBA (Press Alt+F11)
- Insert a new module (Insert > Module)
Second - paste the following function in your new module (Reference):
Function Reverse(Text As String) As String
Dim i As Integer
Dim StrNew As String
Dim strOld As String
strOld = Trim(Text)
For i = 1 To Len(strOld)
StrNew = Mid(strOld, i, 1) & StrNew
Next i
Reverse = StrNew
End Function
Now you should be able to use the Reverse function in your spreadsheet
I found an alternative that doesn't require VBA at https://exceljet.net/formula/reverse-text-string
The formula is
=TEXTJOIN("",1,MID(B5,ABS(ROW(INDIRECT("1:"&LEN(B5)))-(LEN(B5)+1)),1))
where B5 is the input cell.