title: How to set values for all columns except one?
body: <p>My code works great, all it does is take events from a spreadsheet and creates them on google calendar.
  However, one of the columns in my spreadsheet contains a formula.  Everytime I run the code, the formula disappears and is replaced by whatever is on that cell at the time.</p>
  
  <p>I know this is where the issue is:</p>
  
  <pre><code>   // Record all event IDs to spreadsheet except for row 7
     range.setValues(data);
  </code></pre>
  
  <p>How can you write a loop to only apply this from row[0] to row[8] but skipping row [7]?</p>
  
  <p>But here is the full code for reference:</p>
  
  <pre><code>function onOpen() {
    var sheet = SpreadsheetApp.getActiveSpreadsheet();
    var entries = [{
      name : "Export Events",
      functionName : "exportEvents"
    }];
    sheet.addMenu("Update Calendar", entries);
  }
  
  //Export events from spreadsheet to calendar//
  function exportEvents() {
    var sheet = SpreadsheetApp.getActiveSheet();
    var headerRows = 1;  // Number of rows of header info (to skip)
    var range = sheet.getDataRange();
    var data = range.getValues();
    var calId = "calendar_ID";
    var cal = CalendarApp.getCalendarById(calId);
    for (i in data) {
      if (i &lt; headerRows) continue; // Skip header row(s)
      var row = data[i];
      var date = new Date(row[0]);  // First column
      var title = row[1];           // Second column
      var tstart = new Date(row[2]);
      tstart.setDate(date.getDate());
      tstart.setMonth(date.getMonth());
      tstart.setYear(date.getYear());
      var tstop = new Date(row[3]);
      tstop.setDate(date.getDate());
      tstop.setMonth(date.getMonth());
      tstop.setYear(date.getYear());
      var loc = row[4];      
      var desc = row[5];
      var complete = row[6];
      var status = row[7];
      var id = row[8];              // Eight column == eventId
      // Check if event already exists, update it if it does
      try {
        var event = cal.getEventSeriesById(id);
      }
      catch (e) {
        // do nothing - we just want to avoid the exception when event doesn't exist
      }
      if (!event) {
        //cal.createEvent(title, new Date("March 3, 2010 08:00:00"), new Date("March 3, 2010 09:00:00"), {description:desc,location:loc});
        var newEvent = cal.createEvent(title, tstart, tstop, {description:"("+status+") "+desc,location:loc}).getId();
        row[8] = newEvent;  // Update the data array with event ID
      }
      else {
        event.setTitle(title);
        event.setDescription("("+status+") "+desc);
        event.setLocation(loc);
        // event.setTime(tstart, tstop); // cannot setTime on eventSeries.
        // ... but we CAN set recurrence!
        var recurrence = CalendarApp.newRecurrence().addDailyRule().times(1);
        event.setRecurrence(recurrence, tstart, tstop);
      }
      debugger;
    }
    // Record all event IDs to spreadsheet except for row 7
    range.setValues(data);
  }
  </code></pre>