Find duplicates within a calendar VBA

Status
Not open for further replies.

pantakos

Board Regular
Joined
Oct 10, 2012
Messages
161
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello all,

I have the below code and I want if it possible to check if the event at the calendar already exists. If yes then dont make a duplicate event. If not create it.

VBA Code:
// Δημιουργία Μενού

function onOpen(){
  const ss = SpreadsheetApp.getActive();
  const menuEntries = [];
  menuEntries.push({name: 'Εισαγωγή σε Ημερολόγιο', functionName: 'scheduleShifts'});
  ss.addMenu('Carousel', menuEntries);
}

//

function scheduleShifts() {
var spreadsheet = SpreadsheetApp.getActiveSheet();
    var calendarID = spreadsheet.getRange("B2").getValue();
    var eventCal = CalendarApp.getCalendarById(calendarID);
    const signups = spreadsheet.getRange("A4:D110")
    .getValues()
    .filter(row => row.every(String));

for (x=0; x<signups.length;x++)

{
    var shift = signups[x];
    var startTime = shift[0];
    var action= shift[2];
    var description= shift[1];
    var endTime= shift[3];
    eventCal.createEvent(action, startTime, endTime, { description: shift[1] } ).setColor(4)
}
}

Here is the shared example sheet

Thank you in advance
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Please note: This is not VBA. This is a Google Sheets file using Google Apps Script.
 
Upvote 0
You are correct , please admin delete this one. I have created a new one.
Thank you
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,224,891
Messages
6,181,614
Members
453,057
Latest member
LE102024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top