I’m working on a project in Google Sheets where I need a consistent color dropdown list across multiple sheets. The source data for the dropdown (text and corresponding colors) is stored in a separate hidden sheet named “Data”, like this:
I’ve successfully created the dropdown using Data Validation with the “List from a range” option, referencing 'Data'!A2:A1000
. However, the dropdown doesn’t show the colors from the Data sheet.
Here is an image illustrates the desired outcome:
My idea is to write a function that:
- Iterates through each cell in the relevant range of the Data sheet.
- Extracts the cell’s fill color and text.
- Sets the corresponding item in the dropdown list to have that color.
Here’s a pseudocode concept:
foreach column in sheet(dataSheet):
foreach row in column:
colour = getFilledColour(column, row);
text = getText(column, row);
setDropDownItemColour(column, text, colour);
Unfortunately, I’m struggling to implement this in Google Apps Scripts.
Is this approach feasible? Are there any built-in Google Sheets features or other techniques I could leverage to achieve this?
Any help or guidance would be greatly appreciated! Thank you.