Formula (or function) to reverse a string?

If cell A1 has MH03AZ3530, for example, is there a formula or function that will give me 0353ZA30HM in cell A2?

Please note this isn’t a duplicate of In Calc, is there a way to reverse the order of text in a cell?


Install the AddIn out of this german thread and use as Arrayfunction:(ctrl+shift+enter or [x]arrayOption in Formula-wizard)


[edit]Sorry-My fault-that Version needs explicitly the Empty String "" as second argument for pyjoin
Formula corrected[/edit]

Could you please include this feature as a standard string function in LibreOffice? Like Excel has done in =StrRev. Thanks!

[edit - by newbie-02]
there is! a working solution in calc,
described and! illustrated with videos by @mikekaganski in the comment series below,
as such is often overlooked - i overlooked it myself -
(and as i’m astonished that it’s possible to edit others users answers),
and as this answer wasn’t an answer before but an enhancement request …
i felt free to place this hint here …

Could you please point to the “StrRev” function documentation for Excel? (There’s none in Excel 2016 AFAIK; there’s a VBA StrReverse, also present in LibreOffice’s VBA compatibility mode.)

I cannot find any documentation, but the functions described here:

As I said, it is not an Excel function, but a VBA function, which you cannot use in Excel as =StrReverse("ABC") (unless you create a special macro); and LibreOffice does have exactly the same function, which was mentioned in my comment.

OK. I realized that I had defined the StrRev function by defining a VBA macro in Excel:

Public Function StrRev(str As String) As String
StrRev = StrReverse(Trim(str))
End Function

Is there any documentation on how I can do this in LibreOffice Calc?

I already gave you the link to the StrReverse documentation (“also present in LibreOffice’s VBA compatibility mode”); there’s no need to do it differently in LibreOffice - you only need to define Option VBASupport 1 in your module, as mentioned in the link above (yes, it’s frustrating when your answers are not even checked).

I have of course had a look the StrReverse documentation. But my question was how one can get this to WORK in LibreOffice. I have tried this out already last year, but I cannot get it working.

Option VBASupport 1

Function StrRev(str As String) As String
StrRev = StrReverse(Trim(str))
End Function

and similar solutions just result in #NULL! when tested. (Yes, it’s frustrating being patronized by tech geeks who don’t understand that the long tail of users by documentation mean an easy usable step-by-step guide…)

Is this usable enough?

As I wrote in my previous reply, this doesn’t work. It works if you put the string to reverse into the function, but not if you refer to another cell, which is of course the main use of such a function.


The problem seems to be, that you don’t take effort to describe what doesn’t work for you in detail. Because - you had been given a usable guide; if something doesn’t work, it’s not enough to write “it doesn’t work”.

Well, as I said, this does not work, at least not on my linux machine. I now tested it out on my windows machine at work, and it works there.


No need for an add-in for this, you can use a matrix formula (to be validated by Ctrl+Shift+Enter):


See InverserTexte.ods


Thanks. But I use the StrRev function very often, so using a matrix formula takes a lot of time. Therefore, I’d prefer one singe function like StrRev also in LibreOffice.


i think the following macro should do what you want. Just put it into Tools → Macros → “Edit Macros” and you can call it from inside any cell like this:

=STRREV("Hello World")

The First argument kann be a cell reference (A1) or direct data (string,number,…), which will be interpreted as a string and reversed

Macro Function:

Function STRREV(data as String)
	Dim out as String
	For i = 0 to Len(data) -1 
		out = out & Mid(data,Len(data) - i,1)
End Function

Hope that helps.

To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!

Have a nice day and let’s (continue to) “Be excellent to each other!”