1
votes

I'm trying to use the Google Sheets script editor to create a set of sheets from a form to create individual sheets named after the value of each cell in column "B" and populated with all the data in rows 1 and X, where X is the value of the row for each sheet.

What I have so far is:

function makeSheets() {

var ss = SpreadsheetApp.getActive();
var sheets = ss.getSheets();
sheets[0].getRange('B2:B100')
    .getValues()
    .forEach(function (el, i) {
        if (el[0] && !ss.getSheetByName(el[0])) ss.insertSheet(el[0], sheets.length +i)
    });
}
1

1 Answers

0
votes

This will create the new sheets with the same header rows (row 1) one the new sheets. I don't understand the X you want to create.

function makeSheets() {
var ss = SpreadsheetApp.getActive();
var sheets = ss.getSheets();
var r1=sheets[0].getRange('1:1').getValues()
sheets[0].getRange('B2:B100')
    .getValues()
    .forEach(function (el, i) {
        if (el[0] && !ss.getSheetByName(el[0])) ss.insertSheet(el[0],   sheets.length +i).getRange('1:1').setValues(r1);
    });
}