I'm having an issue with google spreadsheets. I want to... have Cell C2 always contain the difference between cell E2 and F2 even if I move the row (i don't want the formula to adapt to that change of rows, the formula should still be E2-F2); so let's say E2 contains 5 and F2 contains 3, C2 would display 2. So let's say I switch row E and row F. Right now the result displayed would still be 2, and the formula in cell C2 would've changed to F2-E2. What I want is the formula not to change, and the result displayed would be -3.
=INDIRECT(E2)-INDIRECT(F2) didn't work for me - it gave me a reference error.
The INDIRECT function expects a string parameter. So you would need to write
=INDIRECT("E2")-INDIRECT("F2")
But the better way to solve your problem would be to use absolute references
=$E$2-$F$2
Related
I have a Google sheet like this: spreadsheet and I am trying to figure out if in column O it is possible to check if there is a value in a cell and then count all empty cells before it in the row? So for example O2 should say 3 and O3 should 5.
I have been trying using =COUNTBLANK for the row, but can't figure out a way to only count backwards from the first value (marked in yellow on the screenshot).
Another solution (in O2)
=BYROW(A2:N,LAMBDA(r,IFERROR(1/COUNTBLANK(
FILTER(r,COLUMN(r)<MIN(IF(r<>"",COLUMN(r)))))^-1)))
Try this in 02 (delete any values below it because it will expand):
=byrow(map(B2:N,lambda(n,if(ISBLANK(n),"",1))),lambda(each,IFERROR(MATCH(1,each,0)-1,"")))
I have a sheet that has blocks of cells. I add them for a total if they don't contain any letter. Letters signify a specific variable or signifier code for tracking. I also want to add the cell value when a cell has an ending code letter. I've tried SUMIF, Substitute, SumProduct and a few others.
For a while I've used the following which worked till the S value changed to another number than "8" which then gave the wrong sum from the range.
=if(countif(D64:Q64,"*S")=0,"",((countif(D64:Q64,"*S"))*8))
In the cell range I have 5 variable groups ending in a letter (A, H, S, C and R) and one group not ending in any letter.
The formula I use to add the cells not containing a letter but have a value is this
=IF(SUM(AA64,(SUMIF(D65:Q65,"<>")),-(COUNTIF(D65:Q65,">=0")*8))>24,24,(SUM(AA64,(SUMIF(D65:Q65,"<>")),-(COUNTIF(D65:Q65,">=0")*8))))
which adds the table data plus the previous lines table data but does not exceed 24.
H is a set value of 6 and doesn't change.
Does anyone know how to add the value of the cells that contain a specific letter?
N (number)
A
S
C
R
H
8.5
H
8A
2S
9
3C
0.5R
17.5
8
2
3
0.5
6
I'd prefer it be a formula usable in Google Sheets because that is where this data is.
Solution:
You can use this formula below column "N" then drag right until below column "H".
=SWITCH(H$1,"N",SUM($A2:$G2),"H",6,SUM(IFERROR(ARRAYFORMULA(VALUE(LEFT($A2:$G2,FIND(H$1,$A2:$G2)-1))),0)))
This is a combination of three formulas:
If the row above is N, sum A2 to G2. This will ignore all the strings.
If the row above is H, output 6.
Else, get the number to the left of the defined suffix, set all others to 0, and get the sum.
Output:
References:
Extract number from string in Google Sheets
An alternative could be to use
=SUMPRODUCT(A3:G3, isnumber(A3:G3))
to compute the sum of the cells with numbers only, and to use
=sum(filter(substitute($A$3:$G$3, I$2,)+0, regexmatch($A$3:$G$3, I$2)))
under the 'A' and drag to the right
Examples
I'm working in a Google Sheets document that has two sheets, Sheet1 and Sheet2. Sheet2 has a cell, A3, with the formula =Sheet1!A3. This pattern holds throughout the column – e.g. A4 in Sheet2 has formula =Sheet1!A4, etc. Without getting into too much detail of the why, essentially the A column in Sheet1 is to be reflected in the A column of Sheet2. My desire is that when Sheet1 is updated, those changes will be reflected in Sheet2.
The problem is that when I add/delete entries into/from column A in Sheet1, Google Sheets automatically updates the formulas in Sheet2 in a way I don't want it to. For example, say I insert a cell above A3 in Sheet1, so that there is now new information in A3 and the previous A3 is now shifted down to A4. When I check out Sheet2 I want the new A3 from Sheet1 to be reflected in Sheet2's A3. However, the formula in Sheet2's A3 cell has now been updated to =Sheet1!A4 (so that Sheet2's A3 still shows the information from Sheet1's original A3), and all subsequent cells have been shifted by one as well. I can see a reason for this auto-updating functionality, but it is a hinderance in this case.
In looking up a solution, I've found out about absolute reference, i.e. changing the formula in A3 to =Sheet1!$A$3, but this unfortunately does not help in my case.
Is there any way to prevent this autoupdating of the cell reference?
On Sheet2 use INDIRECT. Example
Add the following formula to Sheet2!A1
=INDIRECT("Sheet1!A:A")
The above will not be "affected" by row/column changes made into Sheet1 because it doesn't make a direct reference to rows/columns on Sheet1.
Non-volatile equivalent of INDIRECT could be INDEX.
=index(Sheet1!a:a, 3)
Unfortunately, filling down for index(Sheet1!a:a, 4), etc is difficult if not impossible. You could represent the 3 with a row reference to a worksheet that will never have rows deleted; e.g. row(sheet2!b3). That shouldn't change unless you add/delete rows on sheet2 while allowing add/delete rows on sheet1.
I would like to plot sparklines (barchart with the value to show in B-row and the max-value in die C-row: see linked file) in every cell from A2 to A5 using ony one arrayformula (=ARRAYFORMULA( ...) in A2 which can plot spakrlines in every cell from A2 to A5.
Link to file: sparkline arrayformula
Thx for any help,
Gerd
SPARKLINE does not work with arrayformula. I think the best you can do is put this in A2 and drag it down past A5. It will pick up new data.
=iferror(SPARKLINE(B2,{"charttype","bar";"max",C2}),"")
Hmm
Make a blank column A:A.
=ARRAYFORMULA(IF(ISBLANK($A$1:$A),"", SPARKLINE({0,1},{"color","#ddd"})))
Say I have 2 columns: (this is extremely simplified)
Data = a number
Result = Data * 1.2
I can put B2 = A2*1.2, then drag and drop B2 down...
and it fills all the other cells, which is perfect.
But can I put this multiplier (1.2) somewhere as a "constant"? (for clarity and being easily editable)
Say I put it in E1, and set B2 = A2*E1.
Now I can't drag and drop anymore (because E1 becomes E2 E3 and so on)
In this example, is there a way to make E1 stay as you drag it down?
Short answer
Use an absolute cell reference or a named range
Explanation
Instead of E1, which is a relative cell reference, use $E$1 which is an absolute cell reference.
An alternative is to to assign a name to the cell E1, let say, "constant"
In the first case the formula will be
=A2*$E$1
In the second case
=A2*constant
References
Spreadsheet - Wikipedia
Name a range of cells - Google Docs Editors Help
I understand that you are asking for "A “constant” in Google spreadsheet?" and later on a "drag down" solution.
You can use the accepted answer, OR ...
Instead of having to drag down (increasing the number of formulas)
Use a single formula in B2
=ArrayFormula(A2:A6*E1)
You can even use it for future entries or now blank cells.
=ArrayFormula(IF(A2:A11<>"",A2:A11*E1,""))
How the formula works
The ArrayFormula will apply the calculation cell*E1 in every single row, IF the cell is not empty/blank "".
IF it is a blank cell it will return a blank cell "".
Functions used:
ArrayFormula
IF
Can you try this in your formula?
Cell B2 type
=A2*$E$1
Then there is no need to drag it down on column E, it will all follow E1.
I believe this solves the problem.
If you really want to drag it down, then why not just put Cell E2
=E1
So that even when you drag, the value will remain 1.2