Skip to main content
Added a two fully workable (and tested) solutions
Source Link

Update (Evan): This isn't built-in feature but it can be added

The first technique uses some spreadsheet function magic

In cell B2 paste the following:

=ARRAYFORMULA(IFERROR(SPLIT(A1:A;"|")))

Then paste your data starting with cell A2. As soon as you enter the data it will automatically split the combined values to a value-per-column using the '|' as a delimiter.

Here's credit to the original author of this approach.

The second approach uses some scripting magic to extend Docs

Goto:

Tools -> Script editor...

Paste the following:

function onOpen() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var menuEntries = [];
  menuEntries.push({ name:"Text to column", functionName:"textToColumn" });
  menuEntries.push({ name:"Text to column (custom separator)", functionName:"txtToColumnCustom" });
  ss.addMenu("Advanced", menuEntries);
}

function txtToColumnCustom() {
  var separator = Browser.inputBox("Text to column","Enter the the separator",Browser.Buttons.OK);
  textToColumn(separator);
}

function textToColumn(separator) {
  var sep = typeof(separator) != 'undefined' ? separator : ',';
  var ss = SpreadsheetApp.getActiveSheet(); 
  var c = ss.getActiveCell();
  var input = c.getValue();
  var values = input.split(sep);
  var row = c.getRow();
  var col = c.getColumn();
  ss.getRange(row,col,1,values.length).setValues(new Array(values));
}

Save and close the script editor. Then, refresh the spreadsheet. It'll take a second to load but you should see a menu called 'Advanced' popup after 'Help' in the toolbar.

To use it:

  • Select the cell containing the values
  • Select 'Advanced' -> 'Text to column (custom separator)'
  • When the prompt pops up enter '|' (without quotes) into the field and hit enter

It's magic, it'll automatically split the values out into columns. If you were wondering the non-custom 'Text to column' function uses commas as separators.

This version only works on one row at a time. I have been doing a lot of custom Google Apps Scripting lately so it literally only took about 20-30 minutes to get this from concept to working. If you want one where you can select and split multiple rows just request it in the comments or use the formula above.

Whatever you do, don't underestimate the power of Google Apps Scripting. In the right hands, it is capable of doing amazing things.

Update (Evan): This isn't built-in feature but it can be added

The first technique uses some spreadsheet function magic

In cell B2 paste the following:

=ARRAYFORMULA(IFERROR(SPLIT(A1:A;"|")))

Then paste your data starting with cell A2. As soon as you enter the data it will automatically split the combined values to a value-per-column using the '|' as a delimiter.

Here's credit to the original author of this approach.

The second approach uses some scripting magic to extend Docs

Goto:

Tools -> Script editor...

Paste the following:

function onOpen() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var menuEntries = [];
  menuEntries.push({ name:"Text to column", functionName:"textToColumn" });
  menuEntries.push({ name:"Text to column (custom separator)", functionName:"txtToColumnCustom" });
  ss.addMenu("Advanced", menuEntries);
}

function txtToColumnCustom() {
  var separator = Browser.inputBox("Text to column","Enter the the separator",Browser.Buttons.OK);
  textToColumn(separator);
}

function textToColumn(separator) {
  var sep = typeof(separator) != 'undefined' ? separator : ',';
  var ss = SpreadsheetApp.getActiveSheet(); 
  var c = ss.getActiveCell();
  var input = c.getValue();
  var values = input.split(sep);
  var row = c.getRow();
  var col = c.getColumn();
  ss.getRange(row,col,1,values.length).setValues(new Array(values));
}

Save and close the script editor. Then, refresh the spreadsheet. It'll take a second to load but you should see a menu called 'Advanced' popup after 'Help' in the toolbar.

To use it:

  • Select the cell containing the values
  • Select 'Advanced' -> 'Text to column (custom separator)'
  • When the prompt pops up enter '|' (without quotes) into the field and hit enter

It's magic, it'll automatically split the values out into columns. If you were wondering the non-custom 'Text to column' function uses commas as separators.

This version only works on one row at a time. I have been doing a lot of custom Google Apps Scripting lately so it literally only took about 20-30 minutes to get this from concept to working. If you want one where you can select and split multiple rows just request it in the comments or use the formula above.

Whatever you do, don't underestimate the power of Google Apps Scripting. In the right hands, it is capable of doing amazing things.

Source Link
Yahel
  • 1.5k
  • 2
  • 11
  • 12

Besides what's already been said:

Lack of text-to-column parsing.

That is, if I have a raw string like

Blah|2|4|5|www.google.com
Foo|2|1|1.2|www.twitter.com

It's trivial to have Excel quickly do a text-to-columns on that, using | as a delimiter. Making data formatting as simple as possible is crucial to people who need to create or interact with data tables on a regular basis.

(You can get much more creative with its use; I regularly format complex, messy data sets with just a few text-to-column interations.)