Hi,
I’m trying to use this script below to create a calendar event from dates and names entered in Sheets. I have one unresolved issue --the code runs successfully, but the issue is that from the given range (A1:C17) only the last row (17) turns into a calendar event. I just don’t get this. Checked so far: Sheets range and formats, all APIs and authorizations.
Here’s the code:
- - -
function CreateEvent () {
var spreadsheet = SpreadsheetApp.getActiveSheet();
var calendarId = 'primary'
var eventCal = CalendarApp.getCalendarById(calendarId);
var signups = spreadsheet.getRange('A1:C17').getValues();
for (x=0; x<signups.length; x++) {
var shift = signups[x];
var startTime = shift[0];
var endTime = shift[1];
var campaignname = shift[2];
}
eventCal.createEvent(campaignname, startTime, endTime);
}
- - -
Image: Sheets range A1:C17
![sheets-a1-c17.png](https://groups.google.com/group/google-apps-script-community/attach/af7d5567f10b/sheets-a1-c17.png?part=0.1&view=1)
Image: Calendar entry from May after running the script, all 16 entries before the last row are absent
![only-name-q.png](https://groups.google.com/group/google-apps-script-community/attach/af7d5567f10b/only-name-q.png?part=0.2&view=1)
I'm at a loss here. Please help!
Kind regards,
//James