Hi In Google Apps Script I need a favour.

I have created a script that will add validations into a set row within a tab when edits are made (on edit). The script creates the validation as I need it to, but I want to automatically add the first value from the validation list, hope that makes sense.

The code I have so far is below:

function Headersizedropdown() {

  var tabLists = "headersizes validations";
  var tabValidation = "Listing2.0";
  var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var datass = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(tabLists);

  var activeCell = ss.getActiveCell();
  
  if(activeCell.getColumn() == 3 && activeCell.getRow() > 7 && ss.getSheetName() == tabValidation){
    
    activeCell.offset(0, 32).clearContent().clearDataValidations();
    
    var CatTeam = datass.getRange(1, 1, 1, datass.getLastColumn()).getValues();
    
    var makeIndex = CatTeam[0].indexOf(activeCell.getValue()) + 1;
    
    if(makeIndex != 0){
    
        var validationRange = datass.getRange(3, makeIndex, datass.getLastRow());
        var validationRule = SpreadsheetApp.newDataValidation().requireValueInRange(validationRange).build();
        activeCell.offset(0, 32).setDataValidation(validationRule)
        activeCell.offset(0, 32).setValue(datass.getRange().getRow() == 3)
  }
  
}
}

activeCell.offset(0, 32).setValue(datass.getRange().getRow() == 3)

It is this final section that I know is wrong, but I have tried several ways but can not get it to work. Hope you can help. Thanks in advance


try this?

activeCell.offset(0,32).setValue(validationRange.getValues()[0][0]);