Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9180311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:01:05+00:00 2026-06-17T18:01:05+00:00

I’ve been using this script to pull Data from Google Calendar into a spreadsheet.

  • 0

I’ve been using this script to pull Data from Google Calendar into a spreadsheet. I have a couple questions for improvements:

  1. Is it possible to have this pull data from multiple calendars to the same spreadsheet without them overwriting each other?
  2. Is it possible to have it add a new column of data to the spreadsheet that marks which calendar each row came from?
  3. Also, how would you go about setting this up to run automatically every 24 hours?

THANKS!

function caltest3(){
  var ss = SpreadsheetApp.openById("SPREADSHEET ID");
  SpreadsheetApp.setActiveSpreadsheet(ss);
  var cal=CalendarApp.getCalendarById("CALENDAR ID");
  var sheet = SpreadsheetApp.getActiveSheet();

  var events = cal.getEvents(new Date("January 1, 2013"), new Date("January 13, 2013"));
for (var i=0;i<events.length;i++) {
  //http://www.google.com/google-d-s/scripts/class_calendarevent.html
      var details=[[events[i].getTitle(), events[i].getStartTime(),            
                    events[i].getEndTime(), events[i].getDescription(),
                    events[i].getLocation()]];
  var row=i+1;
  var range=sheet.getRange(row+1,1,1,5);
  range.setValues(details);
    }
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:01:06+00:00Added an answer on June 17, 2026 at 6:01 pm

    Short answers then an example:

    1. You cannot do this with a single call to the CalendarApp, but if you loop through a list of calendarIds and add the resultant events for that calendar to an array, you can then sort this array and put this to the spreadsheet
    2. Simply add the calendar name (or id) as another item in your details array, just remember to increase your range column count by 1
    3. Add a script trigger to whatever period you want, the documentation describes this best.

    Whether you are building an array of calendar events from multiple calendars or just one, adding them to an array in a loop and then writing them to the spreadsheet outside any loop is better practice than writing row by row as every time you call the getRange() & setValues methods they are separate API calls and these calls are most expensive in time for Apps Script. Call each only once with a range to suit your data and your script will run an order of magnitude quicker.

    Script below illustrates answers 1 & 2. Your needs may vary if you are setting a timer to this as you may be wanting to affect the period of time you are querying?

    function caltest3(){
    
      var ss = SpreadsheetApp.openById( 'spreadsheetId' ),
          sheet = ss.getSheetByName( 'sheetName' ),
          cals = ['id1', 'id2', 'id3'], c, cal, calName,
          start = new Date( 'whenever' ), end = new Date( 'whenever' ),
          events, i, details,
          eventslog = [], e,
          rows = [], range;
    
      for (c = 0; c < cals.length; c += 1) {
    
        cal = CalendarApp.getCalendarById(cals[c]);
        calName = cal.getTitle();
        events = cal.getEvents(start, end);
    
        // add the events of the current calendar to the array of all events
        eventslog = eventslog.concat(
          events.map(function(event) {
            return {
              time: new Date(event.getStartTime()).getTime(), // sort by this
              details: [
                event.getTitle(),
                event.getStartTime(),
                event.getEndTime(),
                event.getDescription(),
                event.getLocation(),
                calName // change calendar info position in array to suit
              ]
            };
          })
        );
      }
    
      // sort array of event so date order can be either way by reversing a & b
      eventslog.sort(function(a, b) { return a.time - b.time; });
    
      rows = eventslog.map(function(entry) { return entry.details; });
    
      range = sheet.getRange(2, 1, rows.length, 6);
      range.setValues(rows);
    }
    

    code spaced out for clarity

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am using jsonparser to parse data and images obtained from json response. When
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a small JavaScript validation script that validates inputs based on Regex. I
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.