Home > OS >  Update a Google sheet cell using document ID
Update a Google sheet cell using document ID

Time:11-24

I often use code like this to update a cell on a google sheet:

var test="stuff for cell";

SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1').getRange('A1').setValue(test);

I now find it necessary to access and update sheets for which I have the ID. Basically, I'm looking for something like this:

var test = "stuff for cell";

var ssID = '1234567';  
    
SpreadsheetApp.**getSpreadsheetByID(ssID)**.getSheetByName('Sheet1').getRange('A1').
setValue(test);

I've looked everywhere, but can't seem to find this type of function. Help would be greatly appreciated.

Thanks!

CodePudding user response:

i believe .openById() is what you're looking for.

SpreadsheetApp.openById(ssID).getSheetByName.....

  • Related