Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a Chips Dropdown in Google Sheet using Apps Script

I have an Apps Script code that dynamically creates a dropdown depending on another one, but the generated dropdown has no chips:

enter image description here

Is there any way I can customize the dropdown style within Apps Script?

The code is the following:

function onEdit() {
  var monthTabs = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];

  var aCell = SpreadsheetApp.getActiveSheet().getActiveCell();
  var aColumn = aCell.getColumn();

  if (aColumn == 4 && monthTabs.includes(SpreadsheetApp.getActiveSheet().getName())) {
    var cellContent = aCell.getValue();
    var range = SpreadsheetApp.getActiveSheet().getRange(aCell.getRow(), aColumn + 1);

    if (cellContent == "") {
      range.clearDataValidations();
    }
    else {
      var sourceRange = SpreadsheetApp.getActiveSpreadsheet().getRangeByName(cellContent);
      var rule = SpreadsheetApp.newDataValidation().requireValueInRange(sourceRange, true).build();
      range.setDataValidation(rule);
    }
  }
}
like image 896
JacK'o'Lantern Avatar asked Oct 29 '25 19:10

JacK'o'Lantern


1 Answers

Currently, there's no way to customize the datavalidation dropdown style using Google apps script or Google sheets api. You may request this feature here

like image 123
TheMaster Avatar answered Oct 31 '25 13:10

TheMaster



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!