You will need to install and use a script to do it.
- In your spreadsheet, select Tools → Script Gallery → Insert....
- Search for
reverse
. You should see String.reverse().
- Click Install, then Authorize.
- 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.
- Select Tools → Script editor...
- Select Blank project
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.
The follow formula will do just that; text-to-column:
A1=5,233,6,2,6,7,2,2,6,6
A2=SPLIT(A1;",")
And the next; text-to-row:
A1=5,233,6,2,6,7,2,2,6,6
A2=TRANSPOSE(SPLIT(A1;","))
UPDATE 03-02-2013
If you split the result of A1
and paste the values, it will give the same result as all the lines of code used in the OP's answer. I gave it a shot at it as well with Google Apps Script and this is what I created: text to column
function mySplit() {
var sh = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var cell = sh.getActiveCell().getValues()[0];
var sCell = cell[0].split(",");
var row = sh.getActiveCell().getRowIndex();
var col = sh.getActiveCell().getColumnIndex();
sh.getRange(row,col+1,1,sCell.length).setValues([sCell]);
}
I simple use the build-in split function to split the result and add it it to the sheet, nothing more and nothing less.
Best Answer
If you're thinking about "loop and if statements", you should look into Google Apps Scripts.
Other than that, it seems you're looking for the
TRANSPOSE
function, in conjunction with theFILTER
function. Take a look at the Google Spreadsheets Function List.If you can tell me the purpose of the
Purchase
column in your example, I might be able to set up a working example.