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,

New contributor

Seprilox is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Here’s another alternative way.

There’s no direct way to influence the color selection chip on the Data Validation itself what you can do instead is use on Edit and just change the background after selecting.

Depending on your end result this could be a helpful work around.

You can try this code using Google App script:

function applyDropdownColor() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');
  var sourceRange = sheet.getRange('A1:A20');
  var backgrounds = sourceRange.getBackgrounds();

  sheet.getRange('B1').setDataValidation(
    SpreadsheetApp.newDataValidation()
      .requireValueInRange(sourceRange, true)
      .build()
  );

  var firstValue = sourceRange.getValues()[0][0];
  if (firstValue) {
    sheet.getRange('B1').setBackground(backgrounds[0][0]);
  }
}

function onEdit(e) {
  updateBackgroundColor(e);
}

function updateBackgroundColor(e) {
  var sheet = e.source.getActiveSheet();
  var targetCell = sheet.getRange('B1');

  if (e.range.getA1Notation() === targetCell.getA1Notation()) {
    var selectedValue = e.value;
    var sourceRange = sheet.getRange('A1:A20');
    var values = sourceRange.getValues();
    var backgrounds = sourceRange.getBackgrounds();

    values.forEach((row, i) => {
      if (row[0] === selectedValue) {
        targetCell.setBackground(backgrounds[i][0]);
      }
    });
  }
}

This script creates a drop-down menu in cell B1 that lets you choose from A1
and changes B1’s background color based on your selection.

The updateBackgroundColor function ensures that when you pick a value from the drop-down, B1’s background color updates match the color in A1.

Sample Output:

Reference/s:

getBackground

onEdit

1

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:

New contributor

user27425627 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

3

Use the colorfulDropdownLists_ script.

For best effect, choose the Arrow display style instead of the Chip display style in dropdown Advanced options.

3

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật