You do not have permission to call openById

I thought that I would throw in a similar issue that I had which brought me to this question, where I received the error You don’t have permission to call by openById. In my case I was trying to call functions from translate.gs which I copied from this example: https://developers.google.com/apps-script/quickstart/docs Note that at the top … Read more

How do you create a “reverse pivot” in Google Sheets?

I wrote a simple general custom function, which is 100% reusable you can unpivot / reverse pivot a table of any size. In your case you could use it like this: =unpivot(A1:D4,1,1,”customer”,”sales”) So you can use it just like any built-in array function in spreadsheet. Please see here 2 examples: https://docs.google.com/spreadsheets/d/12TBoX2UI_Yu2MA2ZN3p9f-cZsySE4et1slwpgjZbSzw/edit#gid=422214765 The following is the … Read more

How to automatically import data from uploaded CSV or XLS file into Google Sheets

You can programmatically import data from a csv file in your Drive into an existing Google Sheet using Google Apps Script, replacing/appending data as needed. Below is some sample code. It assumes that: a) you have a designated folder in your Drive where the CSV file is saved/uploaded to; b) the CSV file is named … Read more

Get column values by column name not column index

The following function retries the value in a column with a given name, in a given row. function getByName(colName, row) { var sheet = SpreadsheetApp.getActiveSheet(); var data = sheet.getDataRange().getValues(); var col = data[0].indexOf(colName); if (col != -1) { return data[row-1][col]; } } Specifically, var col = data[0].indexOf(colName); looks up the given name in the top … Read more

Creating anchored comments programmatically in Google Docs

The Anchoring Comments feature from the Google Drive API is intended for non-Google Docs editors files, not for Google Documents. See https://youtu.be/ZBU52nacbLw?t=5m26s (credit to Bryan P who shared this URL through a comment) Unfortunatelly at this time the Document Service from Google Apps Script doesn’t include a Class Comment to handle comments and discussions. At … Read more

Is there a way to evaluate a formula that is stored in a cell?

No, there’s no equivalent to Excel’s EVALUATE() in Google Sheets. There’s long history behind this one, see this old post for instance. If you’re just interested in simple math (as shown in your question), that can be done easily with a custom function. function doMath( formula ) { // Strip leading “=” if there if … Read more