Reputation: 57
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();
}
=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
Reputation: 57
I got this fixed by giving the following formula
=FCOLOR("A2:A",A2:A)
Upvotes: 0
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
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