Insert formula through google sheet column - google-sheets

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.

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),))

ArrayFormula is good solution. I prefer limiting the used range by it's size. If your data has no blanks, you could also use this formula:
=ARRAYFORMULA(IMAGE(OFFSET(A2,,,COUNTA(A:A)))
Paste it in cell B2.
offset + counta will give range A2:A6 in your case.

Related

How to display both the formula and the result of the formula in one cell?

I would like to have a cell in Google Sheets to display the entire summation for example:
5+5 = 10
If I do the following:
=5+5
The cell will only show 10 it doesn't show the 5+5.
Another way I have tried is:
="5+5 = " &5+5
While this works, if I need to modify the formula I have to change the formula in the quotes and after the & sign.
Is there a way to simplify this so that if I need to change the formula, I only have to touch the formula once in the cell?
google-sheets
You can do this via FORMULATEXT
In A1,
=REGEXREPLACE(FORMULATEXT(A1),".*?&",)&"="&(5+5)
It will display:
(5+5)=10
You only need to modify the math and details are retrieved through FORMULATEXT and REGEX is used to remove FORMULATEXT itself. Furthermore, there won't be circular reference as the docs say,
If the cell passed into FORMULATEXT references the cell that contains the FORMULATEXT formula, then FORMULATEXT will properly handle this and avoid a circular reference.
excel
You just need to use RIGHT and FIND instead of REGEXREPLACE.
try:
=SUBSTITUTE(FORMULATEXT(A1)&"="&A1, "=";;1)
arrayformula would be:
=IFNA(BYROW(A1:A10; LAMBDA(xx; SUBSTITUTE(FORMULATEXT(xx)&"="&xx; "=";;1))))

Apply same formula to every cell

I have a sheet with several numbers, which I want to convert to percentage. These are scores imported from a form, where the maximum score is 5.
According to the bellow image, the cell B2, I applied a basic formula =(3/5)*100% to convert three to 60%.
In order to avoid copy and paste the same formula into all cells, is there any formula to find all the cells and apply its value, divide per 5 and multiple per 100%? I thought something similar to Javascript such as (this/5)*100%.
https://docs.google.com/spreadsheets/d/1ZtqJaXy1pHkjk1sywGfSodo0FcOoLlkou79cZBk-jmU/edit?usp=sharing
you could treat it as array and on Sheet2 use:
=ARRAYFORMULA(IF(Sheet1!B2:AA="";;(Sheet1!B2:AA/5)*100%))
demo sheet
I've also looked for a solution to this for some time.
I don't think it's possible as a cell can only hold one value and the moment you try to change that value, it will delete the value.
Your best bet is to create a different table on the same sheet that references the specified values, then copy and paste the results (values only).
Just create a second Sheet, then in cell B2 of Sheet2 use the formula =Sheet1!B2/5*100%.
Then copy the formula to all cells of Sheet2.

IMPORTRANGE built dynamically, pulls in as string when it lands in cell instead of the formula

I'm building linked google sheets. In the scenario I need to build the IMPORTRANGE formula dynamically from a concatenation.
The IMPORTRANGE formula which I want to populate in the cell is: =IMPORTRANGE("https://docs.google.com/spreadsheets/d/1MULmCled46FWynp7fmGGAQBflUn6lpgltl9XNqXvnJ8/edit#gid=328066760","Competitive Analysis!E9")
The URL in the formula will change based on some variables.
I have built the IMPORTRANGE formula in a different sheet using concatenation and am inserting into the cell with a vlookup:
=VLOOKUP(E2,'Tool Setup'!A7:F22,6,FALSE)
The VLOOKUP formula causes the IMPORTRANGE FORMULA to show up as string text, not as a formula.
Is there something I can do to force it to register as a formula in the cell?
I don't think you can do it quite the way you've described.
What should work is to have the root of the formula in the cell where you want the data to end up, but then complete it with data pulled from another cell (or sheet).
For example, in the cell where you have the VLOOKUP, change that to be:
=IMPORTRANGE(VLOOKUP(E2,'Tool Setup'!A7:F22,6,FALSE),VLOOKUP(.....))
where the first VLOOKUP would bring back the URL, and the second would bring back the range.
I believe this should work.

Making a formula that checks for a sheet with the same name as the cell next to it

I have this formula which sums up several columns in another sheet. The sheet that the formula is referencing to always has the same name as the cell next to it.
Instead of having to rewrite the formula for every cell in the column, is there a way I can just simply check for a sheet with the same name as the cell next to it? The cell ranges will always be the same.
You should use INDIRECT formula. This allows you to write references as strings.
Instead of 'Round 3'!C5:C you can write: INDIRECT("'"&C2&"'!C5:C") (assuming that word Round 3 is in C3).
Whole function looks like this (assuming that active cell is D2)
=SUM(INDIRECT("'"&C2&"'!C5:C"),INDIRECT("'"&C2&"'!G5:G"),INDIRECT("'"&C2&"'!K5:K"),INDIRECT("'"&C2&"'!O5:O"),INDIRECT("'"&C2&"'!S5:S"))

Using the same formula for each row in sheet

I want for every row in my sheet to calculate a score using a formula. So the same formula for each row. I tried this:
=ARRAYFORMULA(min((((C3:C100)/4)+((K3:K100)*4/10)+(M3:M100)+((N3:N100)/2.5)+((O3:O100)/5)+(R3:R100)+(T3:T100)+((P3:P100)/3)+(V3:V100))/23))
But it does calculate at all, for any row. (I am starting from row 3)
Why does it act like this? Any suggestions?
It's always best to provide us a link to your sheet, so we can see what you're trying to accomplish (or at least create a copy without sensitive data and share that).
If you want the same exact formula for each row, you will get the same exact result with your current formula. Also, do you mean to SUM the range values you have provided inside the formula? If so, you need to alter your formula to look like this:
=ARRAYFORMULA(min((((sum(C3:C100)/4)+(sum(K3:K100)*4/10)+sum(M3:M100)+(sum(N3:N100)/2.5)+(sum(O3:O100)/5)+sum(R3:R100)+sum(T3:T100)+(sum(P3:P100)/3)+SUM(V3:V100))/23)))
Please be more specific about exactly what you want the formula to calculate on each row. If it's on row 20, for example, do you still want rows 3-100 to be considered? Or just rows 20-100? WHAT data do you need to be considered on each row's formula, in other words?
Here's a sheet I created to try to understand what you want:
https://docs.google.com/spreadsheets/d/1GRdU6NLMWx2xPXDNp21VzYRQRj6cjNbL4RGVUV2x8Wk/edit?usp=sharing

Resources