![]() Step 3 - Use the function to populate the HEX codes in the spreadsheet ![]() Therefore, just knowing the value contained in the cell will not work and we need to explicitly tell the function the coordinates of the cell. In this case, the function needs to know the coordinates of the cell in order to extract its background color. ![]() So, the function will not know which cell or range the values came from. When you call a custom function with a cell or a range as input, only the values in the cell or range are passed to the function. Why do we need to pass the row and column coordinates to the custom function? Why not just reference the cell directly like you would in other functions? The function takes the row and column coordinates of a single cell and it returns the background color of the cell. The above code creates a custom function that you can use from your spreadsheet like any other built-in function. Var background = SpreadsheetApp.getActive().getDataRange().getCell(row, column).getBackground() * The Hexadecimal value of the cell's background color. * Returns the Hexadecimal value of a cell's background color. Open the script editor from the Tools menu (Tools -> Script editor) and replace the code in the editor with the code below. Step 1 - Create a Google Sheets spreadsheet and fill a couple of cells with different colors Step 2 - Write a Custom Function to return the HEX code of a cell's background color You know how to create a Custom Function using Google Apps Script. You're familiar with HTML color codes: What they are and how to use them. You're familiar with the basics of Google Sheets. In this tutorial, I'll show you how to get the Hexadecimal codes (also known as HTML color codes) of the colors in Google Sheets' color picker. ![]() How to get the Hexadecimal codes of colors in Google Sheets
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |