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

153
Views
Google Sheets get Background color formula

I set up this custom function that returns the background color of a certain cell:

/* Returns the Hexadecimal value of a cell's background color.
 *
 * @param {number} row The cell's row number.
 * @param {number} column The cell's column number.
 * @return The Hexadecimal value of the cell's background color.
 * @customfunction
 */
function BGHEX(row, column) {
  var background = SpreadsheetApp.getActive().getDataRange().getCell(row, column).getBackground();
  return background;
}

At first it worked, but when I applied the script to a button, it started throwing the following mistake:

Error
Exception: The parameters (null,null) don't match the method signature for SpreadsheetApp.Range.getCell.

Any one has an idea of why it stopped working all of a sudden and how to fix it?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You might be able to do it like this

function BGHEX() {
  let r = SpreadsheetApp.getUi().prompt("Get Row and Column","Enter row , column",SpreadsheetApp.getUi().ButtonSet.OK);
  let t  = r.getResponseText().split(',');
  var background = SpreadsheetApp.getActiveSheet().getRange(t[0], t[1]).getBackground();
  Logger.log(background);
  return background;
}

or this way by selecting the cell

function BGHEX() {
  var background = SpreadsheetApp.getCurrentCell().getBackground();
  Logger.log(background);
  return background;
}
about 4 years ago · Juan Pablo Isaza Report

0

The function has two parameters, row and column, both are required as they are used as the getCell parameters.

To use this in a button, you have to someway provide the required parameters:

  1. provide default values,
  2. use a user interface, i.e. a prompt or a dialog to ask the user for the parameters

Or set the cell to be used with getBackground() without requiring the row and column parameters, i.e. by using getActiveCell.

about 4 years ago · Juan Pablo Isaza Report
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!