Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

211
Vistas
Returning a Random Cell Value

I'm trying to use google scripts to select a random row from google sheets and return some of the cell values in those rows to email to me.

Here's what I have so far:

function sendEmails() {

  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheets()[0];

  var numRows = sheet.getLastRow();
  var randomNumber = Math.random() * numRows; 

  var bodyTitle = SpreadsheetApp.getActiveSpreadsheet().getRange(3, randomNumber).getValue();
  var bodyHighlight = getActiveSpreadsheet().getRange(D + randomNumber).getValue();
  var bodyLink = getActiveSpreadsheet().getRange(B + randomNumber).getValue();

var body = bodyTitle + " | " + bodyLink + " | " + bodyHighlight; 

  var recipient = "x@gmail.com";
  var subject = "resurfaced highlights";
  var body = "test";
  MailApp.sendEmail(recipient, subject, body);
}

I'm currently getting an error that says

Error
Exception: The parameters (String,number) don't match the method signature for SpreadsheetApp.Spreadsheet.getRange. sendEmails @ send emails.gs:9

Does anyone know how I'd go about formatting this properly so as to avoid this error?

about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda