简体   繁体   中英

Can I run function of multiple Google sheets from Master Google Sheet?

I have created 10 Google sheets ( copies of parent sheet) which has the same code seperately. I want to run some function in all 10 Google sheets from the Parent Google sheet. For Example I want to run the following function in all 10 sheets without opening them from the parent Google sheet. Ex to delete all Entries in 10 sheets

function deleteentries ()

Is it possible by using Google sheet url? Or provide me any other solution.

I am new to appScript so explain your answer step by step.

Thank you for you help.

Collect all sheet IDs in your master project, put them into array and trigger the function for each of them within for loop, where you loop the array with sheet IDs.

 var sheets = ['sheet1 id as string', 'sheet2 id as string'];
    
    function loopAndDoSomething(){
      for (var d=0; sheets.length; d++){
         deleteentries(sheets[d]);
      }
    }

you send sheet id as function parameter and in deleteentries() you can open that sheet by ID and do something with it. That would be one possible approach.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM