# 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?

edit retag close merge delete

Sort by » oldest newest most voted

Hallo

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

=PYJOIN(MID($A$1;LEN($A$1)+1-ROW(OFFSET($A$1;0;0;LEN($A$1)));1);"")


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

more

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

more

1

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.)

( 2018-12-08 07:09:00 +0200 )edit

I cannot find any documentation, but the functions described here: https://docs.microsoft.com/en-us/offi...

( 2018-12-09 08:52:37 +0200 )edit

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.

( 2018-12-09 11:21:52 +0200 )edit

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?

( 2019-09-02 12:47:31 +0200 )edit

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).

( 2019-09-02 12:51:53 +0200 )edit

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...)

( 2019-09-02 19:06:33 +0200 )edit
( 2019-09-02 19:13:27 +0200 )edit

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.

( 2019-09-03 04:48:02 +0200 )edit

Sigh.

http://youtu.be/R3TLALJxzic?hd=1

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".

( 2019-09-03 06:03:40 +0200 )edit

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.

( 2019-09-03 06:20:29 +0200 )edit

Hi

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

=CONCAT(MID($A1;LEN($A1)+1-ROW(INDIRECT("A1:A"&LEN(\$A1)));1))


Regards

more