This is the Google App Script I use to automate routines taking place in Google Workspace products using Google's App Script (aka JavaScript).
Never used Google's App Script before? Below you'll find basic instructions on how to use these scripts in Sheets, Docs, and GMail.
Click on Extentions > Apps Script. Delete the myFunction() that is already in the editor and copy/paste my code in.
Now click on Save (or Command + S) and then Run (or Commandn + R).
The first time you run the script it will ask you to give it permissions, click Allow.
Now sit back and wait because while App Script is useful, it is painfully slow.
You'll know when the code has finished running because a new tab called CPC Analysis will pop up.