AyKay
AyKay

Reputation: 1

Change dropdown list item based on another cells value

So I'm trying to figure out a way where if the two cells match in numbers, the dropdown list item changes to "stopp".

See the example here: Example

What I want it to do is when the column G has the same number as the column H, it changes the status to "Stopp".

Could someone help?

Upvotes: 0

Views: 531

Answers (1)

Oriol Castander
Oriol Castander

Reputation: 648

Unfortunately, this is not possible to do directly in Google Sheets, you would need to incorporate some Apps Script to extend Google Sheets.

With Apps Script, you could simply create a function to check and update the values, or you could do it automatically with triggers. Specifically, the most useful trigger in this situation would be the onEdit() trigger (you can read more about it here), since it would run automatically every time that the document is edited.

function onEdit(e) {
  var sheet = SpreadsheetApp.getActiveSheet();

  var column1Index = 7; //LETTER G
  var column2Index = 8; //LETTER H
  var outputColumnIndex = 9; //LETTER I

  var numberOfRowsToCheck = 10;

  var column1Values = sheet.getRange(1,column1Index,numberOfRowsToCheck,1).getValues();
  var column2Values = sheet.getRange(1,column2Index,numberOfRowsToCheck,1).getValues();

  for (var i=0;i<column1Values.length;i++){
    if(column1Values[i][0] == column2Values[i][0]){
      sheet.getRange(i+1, outputColumnIndex).setValue("Stop");
    }
  }
  
}

Upvotes: 1

Related Questions