Search code examples
google-sheetsgoogle-sheets-formulacustom-function

Very Basic Function to compare strings or numbers


I want to create a Custom Function in my google sheet, which will take few inputs and compare them below is the example please:

I know this is very simple but when I try to save this code this give me the below error.

Missing ; before statement. (line 6, file "Code")Dismiss


Solution

  • Your function can be written in plain JavaScript for Google Apps Script:

    function testFunction(A1,B1,C1) { 
            // check if all the three conditions are met
         if (A1 == "Lion" && B1 == "Cheeta" && C1 == 1) {
            // if they're met, return Cat_Family_Exists
           return "Cat_Family_Exists"; }
            // else return Cheeta
           else {
           return "Cheeta";
             };
    
    };
    

    However, if you want to directly get the data out of a sheet, you might want to have a look at the docs.