1

I'm trying to pull data from an Adwords report to a Google Sheet through an Adwords script. This will be done on a daily basis. Every time the Adwords script runs, a new tab is created (and an old one is to be deleted) on the Google sheet. I'm trying to figure out how to use the 'Creation of a New Tab' event to trigger a script in GSheets that will run a (V)lookup between the newly created tab and an existing tab on the Sheet. So essentially this whole process summed up is as follows:

i) Adwords script to pull data to a G Sheet daily - done
ii) G Sheet script to look up a value in the new tab and compare against a value in an existing tab. - currently stuck
iii) Build yet another tab "Tab C" to collect the records with different values
iv) G Sheet script to send email notification with output of "Tab C"
v) G Sheet script to Delete an older tab

As you can imagine, this is way beyond my coding skills at the moment. So any ideas appreciated.

  • On Google Sheets context a custom function is a user defined spreadsheet function. – Rubén Feb 21 at 16:28
0

The closest to 'Creation of a New Tab' event is the Change event but this and the other events triggered by "actions" only works for changes made by a user through the Google Sheets user interface.

In order to make the tasks after the creation of the new sheet (tab), the "first option" is to modify the Adwords script by adding the corresponding commands after the code line that creates the sheet.

If you don't want or can't do that here are some alternatives

  • use a time-driven trigger programmed to run a certain time after the Adwords script run.
  • use an open trigger that runs every time that the spreadsheet is open.
  • add a button or custom menu to manually trigger the script.
  • use the Google Apps Script IDE to run the script.

References

  • function newSheet(e) { Logger.log(e.changeType); if (e.changeType == 'INSERT_GRID') { // vlookup function to follow } would the above not work? Thanks btw. Time-driven trigger might be a possibility if this breaks. What changes would you propose to the adwords script? – Sanket Dhume Feb 21 at 16:54
  • @SanketDhume I don't know the Adwords script, so I can't propose changes to it. I made a small change to my answer. – Rubén Feb 21 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.