I want to copy and transpose column A,B,C from data sheet TO Natip sheet, regt sheet, provK sheet ie column A copy and transpose to Natip sheet, column B copy and transpose to
regt sheet , column C copy and transpose to provK sheet . when copying and transposing, empty cell should be ignored. please help me out
function trans1() {
let ss = SpreadsheetApp.getActiveSpreadsheet();
let shtIn = ss.getSheetByName("data");
let ssS = SpreadsheetApp.openById("17cRhuKDDqjCRFcMK");
let shtOut = ssS.getSheetByName("natip");
let responses = shtIn.getRange("A3:A").getValues();
//responses is a 2d array that looks like this [[a],[b],[c]]
//first transpose it
let transResp = responses[0].map((resp,i)=>responses.map(r => r[i]))
//we now have [[a,b,c]]
//BUT this is still 2d array. the appendRow function needs a 1d array
//So... you can do one of two things...
//1. just use the first row
shtOut.appendRow(transResp[0])
//2. you can use array.flat()
//shtOut.appendRow(transResp.flat())
let ss1 = SpreadsheetApp.getActiveSpreadsheet();
let shtIn1 = ss1.getSheetByName("data");
let ssS1 = SpreadsheetApp.openById("17cRhuKDDqjCRFc");
let shtOut1 = ssS.getSheetByName("regt");
let responses1 = shtIn1.getRange("B3:B").getValues();
//responses is a 2d array that looks like this [[a],[b],[c]]
//first transpose it
let transResp1 = responses[0].map((resp,i)=>responses1.map(r => r[i]))
//we now have [[a,b,c]]
//BUT this is still 2d array. the appendRow function needs a 1d array
//So... you can do one of two things...
//1. just use the first row
shtOut1.appendRow(transResp1[0])
//2. you can use array.flat()
//shtOut.appendRow(transResp.flat())
let ss2 = SpreadsheetApp.getActiveSpreadsheet();
let shtIn2 = ss2.getSheetByName("data");
let ssS2 = SpreadsheetApp.openById("17cRhuKDDqjCR");
let shtOut2 = ssS2.getSheetByName("provK");
let responses2 = shtIn2.getRange("C3:O").getValues();
//responses is a 2d array that looks like this [[a],[b],[c]]
//first transpose it
let transResp2 = responses2[0].map((resp,i)=>responses.map(r => r[i]))
//we now have [[a,b,c]]
//BUT this is still 2d array. the appendRow function needs a 1d array
//So... you can do one of two things...
//1. just use the first row
shtOut2.appendRow(transResp2[0])
//2. you can use array.flat()
//shtOut.appendRow(transResp.flat())