I want to create a script function that I will use with daily triggers:

  • function will subtract "Daily Fees" (a cell value that changes daily from "Open Trades" sheet) / from "Cash" (a cell in another sheet "Dashboard") and will set the value of the remaining Cash in the same cell (Cash from Dashboard)

Formula -> 'Dashboard'!O5 = 'Dashboard'!O5 - 'Open Trades'!M4

I'm very new to script and Here is my best try:

function substract(){
  var ss = SpreadsheetApp.getActiveSheet();
  var dash = ss.getSheetName('Dashboard');
  var a = dash.getRange("O5").getvalue;
  var cash = ss.getSheetName('Open Trades');
  var b = cash.getRange("M4").getvalue;


However this gives me this error:

Exception: The parameters (String) don't match the method signature for SpreadsheetApp.Sheet.getSheetName.
substract   @ Daily Fees.gs:3
  • Please show what you tried and add a brief description of your search efforts as is suggested in How to Ask.
    – Rubén
    Jan 22, 2022 at 16:50
  • Just added my best effort until now Jan 22, 2022 at 19:49

1 Answer 1


The script has several problems.

Start by replacing

var ss = SpreadsheetApp.getActiveSheet();


var ss = SpreadsheetApp.getActiveSpreadsheet();

also replace getvalue by getValue() and setvalue(a-b) by setValue(a-b)


  • 1
    Followed your tips & also changed ss.getSheetName to ss.getSheetByName and the script works now! Thanks Jan 23, 2022 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.