0
votes

I have google spreadsheet with a column of different products. In another sheet I have a column where each cell contains a dropdown menu populated by the products in the other sheet. I want to program my spreadsheet so that every time a product is selected in the dropdown menu a counter next to the product is incremented. How can I do this?

1
Can you share an example spreadsheet. Is hard to work out what you are looking for. - eddyparkinson

1 Answers

0
votes

If I understood your question correctly, with this piece of code it is possible:

Code

function onEdit(e) {
  if(e.range.getA1Notation() == "A2") {
    var sCounter = e.source.getRange("B2");
    var counter = sCounter.getValue();
    if(counter === 0) {
      counter = 1;
    } else {
      counter ++;
    }
    sCounter.setValue(counter);
  }        
}

Example

I've created an example file for you: Dropdown Counter

Remark

This script will only execute if the cell is active in A2.