title: Google Apps Script adds extra blank questions to Form Responses sheet when importing from Google Sheets
body: <p>I am using Google Apps Script to add questions from a Google Sheets into a Google Form. The lists are read from two separate arrays and added as individual Grid type questions. I also set the Sheet as the destination for the Form results.</p>
  
  <p>When I run the script, the Form gets updated perfectly. If there are 10 items to be added, 10 questions are added to the Form. However, in the Form Responses sheet that is linked, there are often times additional columns titled " [Row 1]" that are added. The number of additional columns and their position change what seems like every other time I run the script. I haven't been able to pick up on any patterns.</p>
  
  <p>I do know that "Row 1" appears as the default first item in a Grid type question when creating the question in the Form's UI. I'm not sure if that has anything to do with it. FYI - grid items allow multiple rows of questions to be added but I am only adding one question. I know there is a multiple choice grid type but I do not like the formatting of it.</p>
  
  <p>As a workaround, I've created a script to delete all of these additional columns but I would really like to figure out what is actually happening.</p>
  
  <p>Any ideas on what is happening?</p>
  
  <p>Here is part of my code:</p>
  
  <pre><code>function editForm()
  {
    var setupSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Setup'); //Create variable for the Setup sheet
    var metricSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Final Metric Statements'); //Create variable for the Metric Statements sheet
    var form = FormApp.openById(setupSheet.getRange("D1").getValue()); //Open form using the form ID from the setup sheet  
  
    var pageFour = form.addPageBreakItem().setTitle('Questions');
  
    var emotLen = 0; //Counter for sub-emotion items
    var featLen = 0; //Counter for sub-feature items
  
  //Count number of items for first list
    while (((metricSheet.getRange("C"+ (emotLen+2)).getValue()) != "") &amp;&amp; ((metricSheet.getRange("C"+ (emotLen+2)).getValue()) != "#N/A")) //Go through sub-emotion column until a blank cell
    {
     emotLen++; //Increase the counter
    }
  
  //Count number of items for second list
    while (((metricSheet.getRange("D"+ (featLen+2)).getValue()) != "") &amp;&amp; ((metricSheet.getRange("D"+ (featLen+2)).getValue()) != "#N/A")) //Go through sub-feature column until a blank cell
    {
     featLen++; //Increase the counter
    }
  
    if (emotLen &gt; 0)
    {
      var emotRng = metricSheet.getRange(2,3,emotLen); //Create a range for sub-emotions based on number of items and column
      var emotArray = emotRng.getValues(); //Copy the items into an array
  
      for (i=0; i &lt;= (emotLen-1); i++)
      {
        var emotItem = form.addGridItem();
        emotItem.setRows(emotArray[i]);
        emotItem.setColumns(['Strongly Disagree', 'Disagree','Slightly Disagree', 'Neither Disagree or Agree', 'Slightly Agree', 'Agree', 'Strongly Agree', 'N/A']);//Add column header
        emotItem.setRequired(true);
      }
    }
  
    if (featLen &gt; 0 )
    {
      var featRng = metricSheet.getRange(2,4,featLen); //Create a range for features based on number of items
      var featArray = featRng.getValues(); //Copy the items into an array
  
      for (i = 0; i &lt;=(featLen-1); i++) //Go through all items in the array
      {
        var featItem = form.addGridItem();//Add item to survey
        featItem.setRows(featArray[i]); //Add row item
        featItem.setColumns(['Strongly Disagree', 'Disagree','Slightly Disagree', 'Neither Disagree or Agree', 'Slightly Agree', 'Agree', 'Strongly Agree', 'N/A']);//Add column header
        featItem.setRequired(true);
      }
    }
  
    //deleteRowColumns();  
  
    //Logger.log(emotLen, emotArray, featLen, featArray); //Logger used for debugging
  }
  </code></pre>
  
  <p>And here is a screenshot of the Form Responses sheet with the additional column:
  <a href="https://i.stack.imgur.com/3fAn9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3fAn9.png" alt="enter image description here"></a></p>