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.
Related
I'm trying to write a formula in Google Sheets that will enable me to sum a range of values across columns, where I can manipulate the number of cells to be summed across the column with a variable. For example:
if my variable is 5, then I want to sum(D3:H3);
and if my variable is 9, then I want to sum(D3:L3)
Furthermore, I want a formula that I can drag across columns so that the range it's summing moves relative to the cell the formula is in. In the example above with the variable=5:
the formula in cell A3 would be sum(D3:H3);
and the formula in cell B3 would be sum(E3:I3)
etc.
I created a sample spreadsheet here for more context.
Thanks for reading!
I've added a sheet ("Erik Help"). See formula in B5:P5.
Here is the B5 formula (which was then dragged across to P5):
=ArrayFormula(SUM(FILTER($B$1:$1,COLUMN($B$1:$1)>(COLUMN()-$B$4),COLUMN($B$1:$1)<=COLUMN())))
There may be an array approach. But since you have such limited data, this is just as effective with less time investment required to develop the solution.
In plain English, the formula reads "Sum the numbers from B1:1 where the column is greater than X rows back and no greater than the current column" (where X is the value set in B4).
paste in column B and drag to the right:
=IF(COLUMN()-1<$B1, "-", SUM(INDIRECT(
ADDRESS(3, COLUMN()-($B1-1))&":"&
ADDRESS(3, COLUMN()))))
I built a Google Spreadsheets tracking the price of certain items in each month. The different items are displayed in row 3:30. Different retailers are displays in Column C:M. Each month is displayed in a different sheet. I want to match (for example) Cell C3 to Cell C3 in the month before and color Red if the price has increased, Green if the price has decreased and remain white if the price is the same. I want to do so for each of the cells C3:M30.
I have managed to find a formula to match cell C3 to C3 then cell C4 to C4 etc. untill cell C30. This is the formula I used:
=C3>INDIRECT("OKTOBER 2020!C"&ROW())
This works fine for Column C, but I can't find a way to incorporate Columns D:M in this formula. Is there a way to incorporate the conditional formatting rule for Columns D:M in the same formula? Or should I just add this formula to each row with the corresponding row Letter?
Answer:
You can do this with an ARRAYFORMULA.
Formula:
=ARRAYFORMULA(C3:M30>INDIRECT("OKTOBER 2020!"&SUBSTITUTE(ADDRESS(1,COLUMN(),4),"1","")&ROW()))
Rundown of this formula:
Creates an ADDRESS of a cell which has a row of 1, the current column index, using a relative reference.
Substitute the hard-coded row number 1 to extract out the column letter
Construct an indirect reference to the current cell using the extracted column letter, the current ROW(), and appending it to the string OKTOBER 2020!
Check if this cell is greater than the current cell
Run this whole formula on the range C3:M30. This can be expanded to cover additional cells, if necessary.
This formula checks if the price has gone up, for which the conditional formatting should reflect as such. You can also do this for when the price has decreased or stayed the same by changing the initial comparison operator:
Price decrease:
=ARRAYFORMULA(C3:M30<INDIRECT("OKTOBER 2020!"&SUBSTITUTE(ADDRESS(1,COLUMN(),4),"1","")&ROW()))
No price change:
=ARRAYFORMULA(C3:M30=INDIRECT("OKTOBER 2020!"&SUBSTITUTE(ADDRESS(1,COLUMN(),4),"1","")&ROW()))
References:
ARRAYFORMULA - Docs Editors Help
INDIRECT - Docs Editors Help
SUBSTITUTE - Docs Editors Help
ADDRESS - Docs Editors Help
COLUMN - Docs Editors Help
ROW - Docs Editors Help
Hi so I'm trying to make a spreadsheet in Google Sheets that takes two numbers and subtracts them and then does it in the next row .
So example the formula in C1 would be "subtract(A1, B1)" in the first row. But then in the next row I would like it to change to "subtract(A2, B2)" and output in C2.
(Without having to go in each C cell and change the formula of course)
So how do I do that and also how do I apply a formula to multiple cells of a row (C1,C2,C3,C4,C5, etc....)
Just put =MINUS(A1,B1) into C1 and then copy it and paste it in the remain rows of column C and the spreadsheet automatically adjusts the row numbers for you.
#Cooper's Answer above is perfect. I'm just giving a alternative here using array formulas, because it's easy.
Put this in D2
=ARRAYFORMULA(MINUS ( B2:B, MULTIPLY( 2.5, QUOTIENT(C2:C,15))))
I've got a spreadsheet made on Google Sheets that contains 11 sheets, and each sheet is a set of things that I'm considering buying.
Some sets contain the same individual pieces as something else.
For example item A might be on sheet A and sheet D.
I'd like to make some kind of formula to highlight all duplicates, so that when I was looking through the sheet I could see whether buying item A will help me complete more than just the set that I'm looking at. So I can look at a set and if it's mostly green I know there's more value in buying it as almost all of the contents will also go towards another set.
I know how to do it so that they glow if they match on the same sheet.
$A2=$B2
However I'm not sure how to do it across sheets, or how I'd include if statements. As the colour would have to change if it matches any cells in column A on any sheet. They're also not in the same order on different sheets so while item A might be in A3 on sheet A, it might be in A17 on sheet D.
I'm not sure how possible something like this is, but I'd appreciate any help.
Google Sheets does not allow direct references to cells in other sheets in conditional formatting formulas. But this can be circumvented with indirect:
= A2 = indirect("Sheet2!A2")
formats the current cell (A2) if it's the same as the contend of A2 on Sheet2.
But you want to check whether the content is duplicated anywhere in column A of another sheet. This can be done with match: select the column A2:A of the present sheet, and add conditional formatting with custom formula
=match(A2, indirect("Sheet2!A2:A"), 0) > 0
Here match returns either the position of found element (a positive number) or #N/A, and the formula evaluates to True in the former case only.
Although the formula says "A2", it can be applied at once to any range that has A2 as its upper left corner.
Google Sheets :
Is it possible to code a cell in a sheet to pull in information from another cell in another sheet, inside the same workbook, by the title of the column that I give it, instead of using something like :
=Sheet1!A2
so that it looks for the Column Header Text to bring in the info no matter where it is in Sheet 1?
I have csv files that vary with some columns, the most important columns, so they won't always be at the same LetterNumber location.
OFFSET in conjunction with MATCH might suit.
=offset(Sheet1!A1,1,match("name1",Sheet1!1:1,0)-1)
A formula such as above should return a value from Row2 (1 lower/higher number than the row of the reference cell A1) of Sheet1 from the column defined by the match function. name1 (a column label) might be anywhere in the first row of Sheet1.