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
.
Web Applications Stack Exchange is a question and answer site for power users of web applications. It only takes a minute to sign up.
Sign up to join this communityWhen 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
.
You will need to install and use a script to do it.
reverse
. You should see String.reverse().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.
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('');
}
Save, return to your spreadsheet, and use =REVERSE(A1)
as described above.
As Ben Collins writes in his Blog you can extract all letters and concatenate them in reverse order using an ArrayFormula without any script:
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.