Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
171 views
in Technique[技术] by (71.8m points)

Converting this Formula into Google Sheet Script but unable to do this

I have been using below formula and trying to convert it into Google Sheet App Script. Because I am using number of such conditions with that formula to populate a single result.

And this formula is becoming bigger and bigger day by day. So looking forward to your response if someone can replace it with a script so i will try to replace other conditions as well.

I have tried to replace it but it was not working even a single line.

Your help will be highly appreciated for this issue.

    =IFERROR(IF(AND($B5<>"",$H5<>""), 
    IF(AND($H5<>"",$I5<>""), 

    IF(OR(AND(DATEDIF($J5,$H5,"D")<1095,$AE5="")),"***MADE ( " &TEXT($H5,"MM-DD-YYYY")&")- " & 
    
IF(AND(DATEDIF($J5,$H5,"D")<1095,$AE5=""), " MIS? "&",",""),"***MADE ( " &TEXT($H5,"MM-DD-YYYY")&")- " &" COMPLETE -2021 ")& 

    IF(OR(AND(DATEDIF($J5,$H5,"D")<1095,$AE5<>""))," DONE=> "& 

    IF(AND(DATEDIF($J5,$H5,"D")<1095,$AE5<>""),"MIS "&TEXT($AE5," MM.DD.YYYY "&", "),""),"")&"***","*******"),"*******"),"ERROR")

Here is the attached Sheet where formula works and give the result. https://docs.google.com/spreadsheets/d/1v3CP7D0V13Tr3ykwPQNkpYVuEB6uNrQjqtwq2bx20-8/edit?usp=sharing

question from:https://stackoverflow.com/questions/65831805/converting-this-formula-into-google-sheet-script-but-unable-to-do-this

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You're making a pretty tedious request for someone to undergo. However, since you say you haven't gotten a single line to work, I'll provide one example below. Hopefully that gets you started, but you probably should consider taking a course or following some videos before asking for more help. A couple I would recommend are:

Both are run by good guys.

Spreadsheet formula:

IF(AND($H5<>"",$I5<>""),

Would be scripted as...

  var ss =SpreadsheetApp.getActiveSheet();
  if(ss.getRange("i5").getValue()!='' &&
    ss.getRange("h5").getValue()!=''){
      //code for when true

  }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...