Ask Your Question
0

Formula (or function) to reverse a string?

asked 2015-10-28 16:02:26 +0200

chimak111 gravatar image

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 flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted
1

answered 2015-10-28 17:35:41 +0200

karolus gravatar image

updated 2015-10-28 19:26:27 +0200

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);"")

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

edit flag offensive delete link more
0

answered 2018-12-08 06:45:25 +0200

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

edit flag offensive delete link more

Comments

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

Mike Kaganski gravatar imageMike Kaganski ( 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...

Philipp gravatar imagePhilipp ( 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.

Mike Kaganski gravatar imageMike Kaganski ( 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?

Philipp gravatar imagePhilipp ( 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).

Mike Kaganski gravatar imageMike Kaganski ( 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...)

Philipp gravatar imagePhilipp ( 2019-09-02 19:06:33 +0200 )edit
Mike Kaganski gravatar imageMike Kaganski ( 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.

Philipp gravatar imagePhilipp ( 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".

Mike Kaganski gravatar imageMike Kaganski ( 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.

Philipp gravatar imagePhilipp ( 2019-09-03 06:20:29 +0200 )edit
0

answered 2018-12-08 07:31:07 +0200

pierre-yves samyn gravatar image

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

See C:\fakepath\InverserTexte.ods

Regards

edit flag offensive delete link more

Comments

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.

Philipp gravatar imagePhilipp ( 2018-12-09 08:59:49 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-10-28 16:02:26 +0200

Seen: 3,138 times

Last updated: Dec 08 '18