Search code examples
google-sheetsspreadsheetarray-formulas

Insert formula through google sheet column


lets say I have a column of URLs in A, I would like to have a script that would insert a formula into the next column over so that it would look like the attached image.

I know how to insert a formula into a single cell through script, but unsure of how to get it down the entire column relative to the cell to the left.


Solution

  • You can use array formula like this:

    =ARRAYFORMULA(IMAGE(A2:A))
    

    or you can wrap it in an if statement to only pull in the images where there is a valid url present with:

     =ARRAYFORMULA(IF(ISURL(A2:A),IMAGE(A2:A),))