Good day everyone. We make a file where we will keep the family budget. Faced the next challenge. There is a “referral” and “product category”. In one direction are collected certain categories of products. There is also an input form (such as a survey), so that we can clog up transactions through mobile phones. So, you need the script to analyze the category of products and automatically put a direction. Suppose the category of "metro", automatically put down the direction "transport" in the adjacent column. I wrote an example script that reads the contents of the current cell and puts the results in the first. The question is how to hang it all up on the input event (hit enter - the script worked)
function myFunction() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; // var first = Browser.inputBox("First value"); if (SpreadsheetApp.getActiveRange().getValue() == "пиво"){ sheet.getRange("A1").setValue(SpreadsheetApp.getActiveRange().getValue());} // sheet.getRange("A1").setValue("First value:"); // sheet.getRange("B1").setValue(first); // var next = Browser.inputBox("Next value"); // sheet.getRange("A2").setValue("Next value:"); // sheet.getRange("B2").setValue(next); // var result = sheet.getRange("B1").getValue() + sheet.getRange("B2").getValue(); // sheet.getRange("A3").setValue("Result:"); // sheet.getRange("B3").setValue(result); // Browser.msgBox("Summ is: " + result); ss.addMenu("Test", [{name: "Test", functionName: "myFunction"}]); }