Google Sheets script for if/then statement - google-sheets

Google Sheets script for if/then statement
Can someone help me write a script for the following:
I need my Google Sheet to input "No" in column W if column J has the word "transfer" in it. Otherwise, it needs to input "N/A".
I currently have the following formula in my Google spreadsheet:
=IF(ISERROR(SEARCH("transfer",J2,1)),"N/A","No")
but as you know, the formula is cleared out once it gets a new entry from the linked Google form.
Any help would be tremendously appreciated.

This might restore your formula. Try attaching it to the form submit trigger.
function fallingFromTheSky(e)
{
var row=e.range.getRow();
e.range.getSheet().getRange(row,23).setFormula('=IF(ISERROR(SEARCH("transfer",J'+ row +',1)),"N/A","No")');
}

Related

Automatically Generating Word Definition from Merriam-Webster Dictionary

I'm trying to modify this formula to automatically provide the definition in Column B when a word is entered in Column A. Currently, the formula looks like this...
=(index(split(concatenate(importxml("https://www.merriam-webster.com/dictionary/"&$A2,"//span[#class='dtText']")),": ",FALSE,TRUE),1,1))
This works, but it doesn't automatically provide the definition when adding new words. I tried modifying the formula using an arrayformula (seen below), but it repeats the definition for the word in A2.
={"Definition";arrayformula(if(A2:A="",,index(split(concatenate(importxml("https://www.merriam-webster.com/dictionary/"&$A2:A,"//span[#class='dtText']")),": ",FALSE,TRUE),1,1)))}
Any ideas on how to fix this? Thanks for your help. Here's the link to the Google Sheet below so you can edit it.
https://docs.google.com/spreadsheets/d/1_OrJwlOHxVXZBKA0GFaiXnRS1x5OCszrR9m3UlMuWRY/edit?usp=sharing
Thanks for your help!
According to this similar article about Use importXML from column of URLs with arrayformula returning same duplicated result in google sheet:
unfortunately, that won't do because ARRAYFORMULA does not support IMOPRTXML formulas. you could try to look up some scripted workaround for this task or give up on one cell solution
Alternative Solution
Perhaps you can use this sample onEdit(e) simple trigger script below instead via Apps Script that is bound to your Spreadsheet file:
Follow this guide on how to add the script as a bound script in your Spreadsheet file:
Sample Script:
function onEdit(e){
var sh = e.range.getSheet();
if(e.range.getColumn() != 1 || e.range.getRow() == 1) return; //ignore if you have not put the word on column A or Col #1 & on row 1
sh.getRange("B"+e.range.getRow()).setFormula("=(index(split(concatenate(importxml(\"https://www.merriam-webster.com/dictionary/"+e.range.getValue()+"\",\"//span[#class='dtText']\")),\": \",FALSE,TRUE),1,1))");
if(e.range.getValue() == "") sh.getRange("B"+e.range.getRow()).clear(); //clear column B row if the adjacent word on column A gets deleted
}
Sample Demonstration
Input the words crystal & believe on cells A2 & A3

Tick checkbox for timestamp in google sheet

I'm creating a request/problem form in google form and responses are viewable and editable in google sheet. In the google sheet, I would like to have a timestamp checkbox for myself to whenever I'm done with the problem.
It is look like this
...
Also, This is the function I put in column K(the timestamp) and the column J is the checkbox column.
=ArrayFormula(IF(ROW(K:K)=1,"DATE",IF(ISBLANK(K:K),"DATE",IF(J:J = true,IF(K:K<>"",K:K,NOW()),""))))
The column K function in sheet
The function for column K work as intended and I just need to manually add the checkbox in column J which is fine enough.
But, the problem is happen when a new form is submitted and update the google sheet. Error message appear " "array result was not expanded because it would overwrite data in K81."
The problem
My objective as I mention above is to have a timestamp checkbox for each problem submitted by google form. Is there are any way to work around this?
This error comes up when a function returns an array that is too big to display because something's in its way.
It could be that K81 has a whitespace character in it. Select the whole column under K1 and press Delete. It should remove any content that's not as obvious that it's there.

Index Match on 2 separate google sheets

Can you please help me with the index match formula with Google sheets on 2 different workbooks? I know the formula on a regular excel sheet but it just won't do the same with google sheets.
I tried the same formula with the regular excel sheet but it just won't work.
try:
=IMPORTRANGE("1VYCPRlno-upguZFmf-dgVG8pXxkXXTx-OWt_VBv4d5c", "Sheet1A:Z")
note: chenge sheet name if needed
note2: first you will see ref error. hover your cursor over it and a button will popup. click on it to authorize the connection/link between your two spreadsheets

stop google sheets creating new row when new data is entered in the form

I have got a Google Spreadsheet that is using a lookup function to lookup name from another sheet according to their ID number but when the ID is entered using the submit form it creates a new row each time and therefore nothing is looked up from the other form.
This is my lookup function currently
=VLOOKUP(C2,'Student Details'!A:D,2,FALSE)
But I have also tried following other examples and put in:
=ArrayFormula(VLOOKUP(C3,'Student Details'!A:D,2,FALSE))
None of these formulas are working for me could someone please advice me where i am going wrong.
Thank you
Try using a range in your arrayformula. E.g: in row 2 try:
=ArrayFormula(IF(LEN(C2:C), VLOOKUP(C2:C,'Student Details'!A:D,2,FALSE),))
make sure the column where you want to use this formula is empty (no data or formula) from row two onwards.

I would like to add some code into my Google Sheet. When I enter a number a url should be created

It's simple but I am new to Google Sheets.
I enter a number in a field in a row. See img below.
When the number is entered I want it to turn into a hyperlink so it clickible.
Web Address example....http://idx.domain.com/details.asp?mls=77777777&aid=BB333833 Everything remains same. all thing that changes is the 77777777 (A2, A3, A4)
You can use onEdit() trigger. Set up an if statement, so that if the first column is edited change it's value to
"=http://idx.domain.com/details.asp?mls=" + your cell value + "&aid=BB333833"
Here is a similar question with an onEdit() trigger
Here is another example which shows how to check for the correct column.
There are plenty of similar question on this topic in SO if you do some searching.

Resources