Raghul
Raghul

Reputation: 57

Foreground color of a text in a cell

I'm trying to create a function to return the color codes of a text in a cell.

Code that I came up with:

function FCOLOR(input) {
  return SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Workspace").getActiveCell().getFontColors();
}
  1. when I type the function, like below it should return the color code in the cell where I use it: =FCOLOR(A1)

The code is working without any errors, but it is not giving the correct color codes, it is reflecting #00000.

Please help me out here, what could've possibly gone wrong.

Upvotes: 0

Views: 400

Answers (3)

Raghul
Raghul

Reputation: 57

I got this fixed by giving the following formula

=FCOLOR("A2:A",A2:A)

Upvotes: 0

raj anand
raj anand

Reputation: 1

Its better if you use with parameter like this

function FCOLOR(row, column) {
return SpreadsheetApp.getActive().getDataRange().getCell(row, column).getFontColors();
}

Get the font color with this formula

=FCOLOR(ROW(A2),COLUMN(A2))

Upvotes: 0

JPV
JPV

Reputation: 27262

Try

function FCOLOR(input) {
return SpreadsheetApp.getActive().getRange(input).getFontColors();
}

and in the spreadsheet pass the range as a string. E.g:

=FCOLOR("A2:A4")

Upvotes: 1

Related Questions