google-sheetsgoogle-apps-script

Transfer background color from cell range to drop down options


Following situation. I have a drop down table in a cell. The drop down options are taken from a range of cells, A1:A20 for example. The cells in A1:A20 have different background colors. When creating the drop down from the range A1:A20, the background color of all drop down options is white.

Is there a way to make it, so that the drop down options have the background color of the corresponding cells?

https://docs.google.com/spreadsheets/d/1dLg9QVy2sHN0fPdB1EGe1mbHi-2EGAZG7r8DuCMlyQI/edit?usp=sharing

I've been looking at tutorials online for the datavalidation rule builder. But not a single one showed how to format the drop down options, if thats even possible,


Solution

  • I can't seem to find a way to do that dynamically (that is, for the colours of the options to change automatically if the reference cells' background colours change) in Apps Script.

    However, if the background colours of your reference range are meant to stay fixed, you can manually format the colour of the drop-down options in the Google Sheets 'Data validation rules' side menu:

    Dropdown example Dropdown formatting