1

I am trying to add a function in a Google Sheet. I am the sheet owner. I have made sure there are no sheet protections.

The function runs for a second, then:

/#ERROR!
"You do not have permission to call setRowHeight() (Line20)"*

I am a novice and know nothing about Signing or publishing or permissions. (I didn't think I needed to know in order to do a function like this one.) I've written other little scripts within Google Sheets that always ran without any special 'permissions' handling... for some reason this one is different.

Anyone have any suggestions why?

The function is as follows:

/**  
 * Modifies the Row Height of every Nth row, Starting at a given Row.  
 *  
 * @param {String} height - the new Row Height to set.  
 * @param {String} every - the multiple of the row numbers to be modified.  
 * @param {String} startingAt - the starting row number to start the multiples from.  
 * @customfunction  
 */  
function setHeights(height,every,startingAt){  
    var ss = SpreadsheetApp.getActiveSpreadsheet();  
    var sheet = ss.getActiveSheet();  
    var range = sheet.getDataRange();  
    var numRows = range.getNumRows();  
   for(var i=1; i<=numRows; i++){  
     if ((i-startingAt)%every!=0){  
     continue;  
   } else {  
     sheet.setRowHeight(i, height);};  
  };  
}  

A test Sheet with the function

3

Custom functions cannot setRowHeight (or for that matter, set anything). Run function directly in script editor instead.

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.