简体   繁体   中英

Fill down formula using a "dictionary" for sheet and column values in Google Apps Script?

I'm looking to do a filldown formula in Google Apps Script. I have a "dictionary" that contains the sheet names and the columns that need to be filled. However I am running into an issue in that I can't get the sheet I need from my key value. The key returns the right string for the sheet name, but.getsheetbyname(key) "can't read property of null".

Here is what I have:

 function filldown(){
    var sheetNames = {
        "PO Tool Import":["A","AK","AL"],
        "Live Orders Aggregated":["A"],
        "Date Lookup":["A"],
        "Containerized POs":["A","B","C","D","E","F","K","R","S","T","U","V","W","X","Y","Z","AA","AB","AC","AD","AE","AF","AG","AH","AI","AJ","AK","AL","AM","AN","AO","AP","AQ","AR","AS","AT"],
        }

for (var key in sheetNames){

    var sheetName = thisBook.getSheetByName(key).getSheetName();

    Logger.log(key);
    Logger.log(sheetNames[key]);
    Logger.log(sheetName);
    };
};

Using these returns, I will then create a formula to return the index for the columns and the length of the filldown/copy to range.

Any suggestions are appreciated.

Ok so after some review it turns out that the key was not the correct string to match the sheet names, as someone had change the names of the sheets in the workbook.

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