Split Text to Column- Random Columns [closed]

Would someone happen to know how I can edit this script so that it detects ANY comma in columns H:BW and splits it into a new column essentially doing "Text to Column" but for multiple columns.

  var ss = SpreadsheetApp.getActiveSpreadsheet(); // Selects the spreadsheet
  var ss1 = ss.getSheetByName("Sample"); // Selects sheet 1
  var data = ss1.getDataRange().getValues(); // Gets all values in the sheet
  for (var i=0;i<data.length;i++) {
    var words = data[i][0].split(", "); // Create an array of all words
    if (words[0].toLowerCase().indexOf(' ') > -1) { // True when the names start with a space
      words.splice(0, 1); // Remove 1 item, starting from position 0 - remove the word that contains space
    }
    ss1.getRange(i+1, 1, 1, words.length).setValues([words])
  }
}

I got the templet to the script here Split text from columns and then rewrite after processing

Here is a sample of what my data looks like https://docs.google.com/spreadsheets/d/1y6AO-1DOHOmRYUDOeCY3THNp2CtBMT4LMff6qQOxpKw/edit?usp=sharing88

As you can see some have numbers and other names, I dont think that would be an issue but through I should point it out. Thank you!



Read more here: https://stackoverflow.com/questions/64950437/split-text-to-column-random-columns

Content Attribution

This content was originally published by Rihco at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: