title: How to set value to a range called from a variable?
body: <p>I'm trying to set a value to a cell but it's showing an error "Range not found".</p>
  
  <p>Following is the code:</p>
  
  <pre><code>function setpush(pushes) {
   var sheet2 = SreadsheetApp.getActiveSpreadsheet().getSheetByName("Alerts").getRange(pushes),
      pushcell = sheet2.getCell(1,1).setValue("PUSH_SENT");
  }
  </code></pre>
  
  <p>Actually, I'm trying to create a custom function for Google Spreadsheet. The variable push is declared at the very starting of the code.</p>
  
  <p>Following is the full code, in case, if the error is due to the code structure.</p>
  
  <pre><code>// Function that you need to call with valid parameters to check when to notify the user and then if all conditions are met then notify the user
  function notify(boolean1, pushes, title, body, url) {
    if(boolean1 == "Yes" &amp;&amp; pushes != "PUSH_SENT") { //// prevent sending duplicate pushes
      sendNotification(pushes, title, body, url); 
      return "Fired";
    } else {
       return 'Not Fired';
    }
  }
  
  /////
  
  // Function that sends notification to an email id
  function sendNotification(pushes, title, body, url) {
  //  Check if edit was made in sendNotificationBoolean, If it was changed then proceed
    //  Get Range of data that we need to proceed from active sheet
    var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("basic").getRange('B19'),
  //      Get email id from range
        email = sheet.getCell(1, 1).getValue();
  
        //  Run a loop and perform appropriate checks to make sure email id is valid and sendNotification boolean is true/yes
    if(email &amp;&amp; email.indexOf("@") != -1) {
  
  /* Variable that stores Payload
   * email: User email
   * type: Type of notification, It can be Note, Link or File. Note suits this. 
   * body: Body of notification, Any message that you want to send goes here.
   * title: Title of notification
   */
  
      var notificationData = {
        "email": email,
        "type": "link",
        "body": body,
        "title": title,
        "url": url
      }
  
  // Important data that has to be sent with every request
  // Change access token to change the user from whom notification'll be sent
      var options = {
        'method': 'post',
        'contentType': 'application/json',
        'headers': {
          'access-token': 'o.13zCbw5nkk9f3VubcJBhZPG2NpCZjTat'
        },
        'payload': JSON.stringify(notificationData)      
      };
  //    Perform a POST request along with options and payload
      UrlFetchApp.fetch("https://api.pushbullet.com/v2/pushes", options);
      {setpush(pushes)}
      }
  }
  
  ///// Set a value for column N
  
  function setpush(pushes) {
   var sheet2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Alerts").getRange(pushes),
      pushcell = sheet2.getCell(1,1).setValue("PUSH_SENT");
  }
  </code></pre>