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

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 Commented Jan 23, 2022 at 11:19

Your Answer

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

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