I\'m completely new to Google Script so bear with me. I\'m attempting to write a script that will take data from several rows and columns and then rewrite it into a single colum
Try this code. The getValues()
method gets a 2 dimensional array. Every inner array is a new row. Every element of each inner array is a cell in a new column. The 2D array can be collapsed into a regular array, with no outer array. But to write the values, a 2D array is needed, so the code below creates a new 2D array. Every inner array only has one value.
function copyRow() {
var ss = SpreadsheetApp.getActive();
var sheet = ss.getActiveSheet();
var numRows = sheet.getLastRow();
var rowIdx = sheet.getActiveRange().getRowIndex();
Logger.log('rowIdx: ' + rowIdx);
//getRange(start row, start column, number of rows, number of columns)
var theValues = sheet.getRange(rowIdx,1,sheet.getLastRow()).getValues();
Logger.log('theValues.length: ' + theValues.length);
theValues = theValues.toString().split(",");//convert 2D array to 1D
Logger.log('theValues.length: ' + theValues.length);
var outerArray = [];
for(var i=0; i
Try it and see if it works, and let me know.