1

I use this formula in Column G

=IF(ISBLANK(A3),"User missing",IFS(C3=E3,0,E3="","Empty Data",C3<>E3,"Wrong Data"))

Applying this formula for 30k data make my sheet slow. Need to convert to script.

As If and IFS is used in same formula, I am facing difficult to convert this to Script.

Condition:

If Column A is Empty then "User Missing"
If A have data, 
then condition is
If E is empty then "Empty Data"
If C and E is not equal then "Wrong Data"
If C and E is equal then 0

1 Answer 1

3

Given that you need the columns A,C,E I used the range A2:E and paste the resulting data in column F:

function myFunction(){
    const ss = SpreadsheetApp.getActiveSpreadsheet();
    const sh = ss.getSheetByName("Sheet1");
    const vals = sh.getRange("A2:E"+sh.getLastRow()).getValues();
    const cvals = []; 
    vals.forEach(r=>{           
         cvals.push( [
                 r[0]==''?"User Missing":
                 r[4]==''?"Empty Data":
                 r[2]!=r[4]?"Wrong Data":0
         ])            
      });
    sh.getRange(2,6,cvals.length,1).setValues(cvals); // paste in column F
}
Sign up to request clarification or add additional context in comments.

4 Comments

Same question here, Instead C,D,E . If I use A,C,E How will be the vals?
please edit your question to update the conditions based on the new columns.
@Moses not sure what you edited. You want to change only the input columns? the conditions are based on columns C,D,E again? Please edit this part and change the column letters you want to use: If Column D is Empty then "User Missing" If D have data, then condition is If E is empty then "Empty Data" If C and E is not equal then "Wrong Data" If C and E is equal then 0
@Moses I updated the answer. let me know if it worked

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.