Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function myFunction() {
- var ss = SpreadsheetApp.getActiveSpreadsheet();
- var sourceSheet = ss.getSheetByName("raw data");
- var destSheet = ss.getSheetByName("myFunction results");
- var sourceData = sourceSheet.getRange(2, 1, sourceSheet.getLastRow() - 1, sourceSheet.getLastColumn()).getValues();
- //Add name to each column, add here if you have more columns
- sourceData.forEach(function (x) {
- x[8] = x[6] + ":\n" + x[8] // col 8 Status
- x[9] = x[6] + ":\n" + x[9] // col 9 Priority
- x[10] = x[6] + ":\n" + x[10] // col 10 Finalized
- x[12] = x[6] + ":\n" + x[12] // col 12 Org Pillars LE
- x[13] = x[6] + ":\n" + x[13] // col 12 Org Pillars REI
- x[14] = x[6] + ":\n" + x[14] // col 12 Org Pillars LOP
- x[15] = x[6] + ":\n" + x[15] // col 12 Org Pillars GF
- });
- var array = sourceData,
- hash = {},
- i, j,
- result,
- item,
- key;
- for (i = 0; i < array.length; i++) {
- item = array[i];
- key = item[0].toString();
- if (!hash[key]) {
- hash[key] = item.slice();
- continue;
- }
- for (j = 1; j < item.length; j++) hash[key][j] = hash[key][j] + "\n" + item[j];
- }
- result = Object.values(hash);
- destSheet.getRange(2, 1, result.length, result[0].length).setValues(result);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement