11

When I enter data in a Google Spreadsheets cell, I would like the text to reverse itself.

For instance, I would like to put in a cell My text and get it converted to txet yM.

15

You will need to install and use a script to do it.

  1. In your spreadsheet, select ToolsScript GalleryInsert....
  2. Search for reverse. You should see String.reverse().
  3. Click Install, then Authorize.
  4. Close the Script Gallery.

To use the script, type =REVERSE(A1) where A1 is the cell with the text you want to reverse.


If you are using the new Google Sheets, the Script Gallery is not available. You will need to create your own custom function.

  1. Select ToolsScript editor...
  2. Select Blank project
  3. Replace the code with:

    /**
     * Reverses the input text.
     *
     * @param {string} input The text to reverse.
     * @return The input text reversed.
     * @customfunction
     */
    function REVERSE(string) {
      if (typeof string != 'string') {
        return null;
      }
      return string.split('').reverse().join('');
    }
    
  4. Save, return to your spreadsheet, and use =REVERSE(A1) as described above.

  • jep works fine - only running on 10000-s of lines of data gives an error because invoked too often – snh_nl Dec 30 '17 at 13:53
3

As Ben Collins writes in his Blog you can extract all letters and concatenate them in reverse order using an ArrayFormula:

Use =ArrayFormula(concatenate(MID(A1,LEN(A1)-ROW(INDIRECT("1:"&LEN(A1)))+1,1)) to reverse the content of A1.

This will not trigger your Google apps limits as easily as the script solution.


example -> example sheet

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.