Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
How do I set a number format in Google Sheets?

I'm trying to set a number format for a message in an email (this script is an email sender that takes data from a cell and puts it into a message). I don't really know how to code, but I've managed to put this together and get it to work well, so that's why my mistake might seem incredibly obvious.

Here's the working script without my attempt at number formatting:

function sendEmails() {
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getSheetByName('Emails'); // change Sheet1 to the name of your sheet
  const data = sh.getRange(2, 1, sh.getLastRow() - 1, 5).getValues();
  data.forEach((r, i) => {
    let sendemailValue = r[1];
    if (sendemailValue === 'X') {
      let lrow = sh.getLastRow();
      let name = r[0];
      let amount = r[2];
      let item = r[3];
      let emailAddress = r[4]; //this is column 5
      let message =
        'Hello ' + name + ', your receipt is ' + amount + ' for your ' + item;
      let subject = 'Your Receipt.';
      if (emailAddress) {
        MailApp.sendEmail(emailAddress, subject, message);
      } else {
        console.log(`Row: ${i + 2}`); //will let you know what row it's failing on
      }
    }
  });
}

And here is my attempt which failed:

function sendEmails() {
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getSheetByName('Emails'); // change Sheet1 to the name of your sheet
  const data = sh.getRange(2, 1, sh.getLastRow() - 1, 5).getValues();
  data.forEach((r, i) => {
    let sendemailValue = r[1];
    if (sendemailValue === 'X') {
      let lrow = sh.getLastRow();
      let name = r[0];
      let amount = r[2];
      amount.setNumberFormat('$#,##0.00;$(#,##0.00)');
      let item = r[3];
      let emailAddress = r[4]; //this is column 5
      let message =
        'Hello ' + name + ', your receipt is $' + amount + ' for your ' + item;
      let subject = 'Your Receipt.';
      if (emailAddress) {
        MailApp.sendEmail(emailAddress, subject, message);
      } else {
        console.log(`Row: ${i + 2}`); //will let you know what row it's failing on
      }
    }
  });
}

The change is that I added amount.setNumberFormat("$#,##0.00;$(#,##0.00)"), which doesn't work.

The error I get is:

"TypeError: amount.setNumberFormat is not a function".

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!