Thursday, September 19, 2024

Set a namespace in dropdown in google sheet

 function setDropdownUsingNamedRange() {

  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var range = sheet.getRange("C3"); // Change this to the cell where you want the dropdown
 
  // Set the named range as the source for the dropdown
  var rule = SpreadsheetApp.newDataValidation()
              .requireValueInRange(SpreadsheetApp.getActiveSpreadsheet().getRangeByName("Caps"), true)
              .build();
             
  range.setDataValidation(rule);
}

No comments:

Post a Comment