Very new to this
cell data looks like:
colx
aa, bbb
oue, hed, ono
hud
need it to become:
colx coly colz
aa, bbb aa bbb
oue, hed, ono oue hed, ono
hud hud
I am needing to split a column on its first delimiter then post back the first part (everything before the first delimiter)in the next column to the right of the original column and post back the rest of the string (everything after the first delimiter) to the 2nd column to the right of the original column
I found the function SplitTheString here: How do I split a string, breaking at a particular character?
I know my code does not work cant get how to fix it, in particular how to output the data
Thanks
function splitColumn() {
var range =getColRng("Elements","colx", 2)
var values = range.getValues());
for (var row in values[0]) {
values[row][0] == SplitTheString(ResultStr);)
}
range.setValues(values);
}
Helper Functions:
function SplitTheString(ResultStr) {
if (ResultStr != null) {
var SplitChars = ', ';
if (ResultStr.indexOf(SplitChars) >= 0) {
var DtlStr = ResultStr.split(SplitChars);
var name = DtlStr[0];
var street = DtlStr[1];
}
}
}
function getColRng(shtName, cheader,startrow) {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(shtName);
var lc = sheet.getMaxColumns();
var lr = sheet.getLastRow();
var hn = HTN(shtName,cheader)
return sheet.getRange(startrow, hn, lr);
}