Apple Numbers, how to reverse the content of a cell?

Cell A1 contains "ABCD".

Expected result in cell B1 "DCBA".


Or, the same thing with binary represented numbers:

Content of A1: 11101010

Expected in B1: 01010111



MacBook Pro 13″, macOS 10.15

Posted on Jan 10, 2021 3:40 AM

Reply
2 replies

Jan 10, 2021 8:26 PM in response to JanekFromCR

Here's a solution that fits in one cell. It consists of one potentially long (but very simple) repeating formula:





TRIM(
MID(LEFT(A1&REPT(" ",11),11),10,1)&
MID(LEFT(A1&REPT(" ",11),11),9,1)&
MID(LEFT(A1&REPT(" ",11),11),8,1)&
MID(LEFT(A1&REPT(" ",11),11),7,1)&
MID(LEFT(A1&REPT(" ",11),11),6,1)&
MID(LEFT(A1&REPT(" ",11),11),5,1)&
MID(LEFT(A1&REPT(" ",11),11),4,1)&
MID(LEFT(A1&REPT(" ",11),11),3,1)&
MID(LEFT(A1&REPT(" ",11),11),2,1)&
MID(LEFT(A1&REPT(" ",11),11),1,1)
)



The formula pads the string with extra spaces, then reads from right to left. Then TRIM removes the extra spaces.


Simply add terms to the formula to accommodate longer strings.


The number within the REPT statement should be at least 1 more than the maximum string length that you have to work with.


The first MID statement will start at the maximum string length which you then decrement in following lines until you reach 1.


When entering long formulas (or even shorter ones) in the Formula Editor you can separate them into lines for easier reading by control-return.


If you copy-paste the formula from above, be sure to select it all, i.e. also select the part that scrolls right out of sight.


SG

Jan 10, 2021 3:29 PM in response to JanekFromCR

Hi Jane,


Not 'elegant', but it does the job, and looks fine if you 'IGNORE the man behind the curtain!!!


After Toto's intervention…

There are two formulas 'pulling the levers' here:


In C2, and filled right to S2, the formula below extracts one character per cell, starting from the last character in the string in A2, and places null strings in the cells beyond those needed for number of characters in that string.


C2: IFERROR(MID($A2,LEN($A2)+3−COLUMN(cell),1),"")

Filled right to column S, and filled down to the last row of the table.


In B2, A, elite selection from All the King's men 'puts Hump Dumpty together again (in reverse order) by concatenating the contents of cells C2 to S2.


B2: CONCATENATE(C3,D3,E3,F3,G3,H3,I3,J3,K3,L3,M3,N3,O3,P3,Q3,R3,S3)

Filled down to the last cell in column B.


Regards,

Barry


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Apple Numbers, how to reverse the content of a cell?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.