Reference a cell using formula? - google-sheets

In Google Sheets I need to reference a cell by (column, row) in a way where I can replace "row" with a formula to find a specific row. In other words I can't use a reference like "A7" because my row is determined by a formula.
Here is the formula that gives me my row number:
=ArrayFormula(MAX(FILTER(ROW(B:B);NOT(ISBLANK(B:B)))))

You can use indirect() to dynamically reference cells
Use: indirect("string that evaluates to a reference")
example: =Indirect("A"&B2) copies the value of the cell with the row in B2 in column A
In your case, it would be (replace [column] with the desired column):
indirect("[column]"&ArrayFormula(MAX(FILTER(ROW(B:B);NOT(ISBLANK(B:B))))))

Related

Conditional Formatting (Google sheet)

I am trying to format a group of cells but I need a custom formula for when the value of a cell is greater than the value of the cell in its column of a specific row it needs to be highlighted
(The highlighted value reference point in the group is in the same row)
Please help 😞
I tried to highlight by using the default option on each column but there are way too many rows
I don't have your exact spreadsheet. Let's say your range goes from A1:Z, and that the column of reference is column E (from each row). Then you can set this formula to:
=A1 > $E1
Change A1 to the first cell of your range and $E1 with the first corresponding column of the first row of the rage (if you start row 3, then put $E3 -- and change the letter ;) )
Let me know if this works for you!

Google Sheets: Find All Instances of a Substring and Return Indices of Cells

Here's the thing I want to do:
For every cell in A2:A, find all instances where the string is a substring of a cell in B2:B, and return all the cell indices (offsetted by a column) concatenated into a single string.
I'm currently using =TEXTJOIN(",",true,IFERROR(ARRAYFORMULA(SEARCH(A2,B$2:B)))) which gives me the first occurrences within the text. I also know how to use the OFFSET function. How do I get the cell indices instead?
picture of sheet
=TEXTJOIN(",",TRUE,FILTER(B:B,REGEXMATCH(C:C,B2)))
FILTER(B:B,REGEXMATCH(C:C,B2) - Filter out all rows in B column if the corresponding row in C column has the specified string (e.g. AA).

Conditional formatting based on adjacent cell value even when the first adjacent cell in row is blank

I would like to colour cell C3 red, as the value is less than the next filled cell on row 3 (E3).
You need custom formula in the formatting rules for range C2:W.
And you can use the formula below for green:
=and(not(isblank(C2)),C2>index(filter(D2:$W2,arrayformula(not(isblank(D2:$W2))))),1,1)
And make another conditional formatting rule with the same range and change > accordingly for red.
Note that the equal case does not have formatting in your example.
To understand why, there are a few components at work. I'll give an outline in case OP or any passer-by wants one.
First is how conditional formatting in Google Sheet works. I will be brief here. The range we put in the rule is C2:W. Google Sheet will use the beginning cell in that range as a reference. For C2:W, the 1st cell is C2. In the formula, the cells are read in terms of relative position to that reference cell. So when evaluating formatting for cell C2, it treats the formula as is. But, for example, when evaluating formatting for cell C3, Google Sheet iterates all non-fixed ranges by 1 row. Another example: for D3, all non-fixed ranges are iterated by 1 row and 1 column.
Whenever the formula evaluates to true, the format will be applied -- although that is subject to further formatting if you have subsequent formatting rules which apply to the given cell.
Next are the components of the conditional formula.
not(isblank(C2)) checks for blank cells and makes the whole formula only true when the cell is non-blank.
For filter() usage, please consult official documentation. I will explain how filter() is applied to your example.
In our use, we are trying to rid of empty cells in the range that is on the same row as the cell in question and goes from the next column to column W. (I am using column W because there is no known end column in your image. Please adjust to your application accordingly.) Same row as C2 means row 2. Hence the digit 2 in D2:$W2. No $ sign for row because row index is meant to iterate through our range C2:W in the formatting rule. No $ sign for D because we mean 1 column next to the cell in question and the exact column index should iterate. We fix column W because the end column does not evolve and is thus not meant to iterate. Neglecting this will not particularly change the result in your example. However, it is good to be clear with the meanings.
arrayformula(not(isblank(D2:$W2))) produces a local row array whose cells are true/false that each represents whether the corresponding cell is non-blank. filter() in turn only keeps cells from D2:$W2 for cells in arrayformula(not(isblank(D2:$W2))) that are true.
We only care about the 1st non-blank cell. To retrieve the 1st cell from a (local) array, we use index(...,1,1). (That said, omitting index() also happens to work for the 1st cell in particular because when comparing a single cell with > or < to an array range, only the 1st cell of the array is used.)
Apply a conditional formatting to the range desired (starting from cell C2) using this formula:
=IF(C2="",FALSE,OFFSET(C2,0,AGGREGATE(15,6,(COLUMN(D2:W2)-COLUMN(D2)+1)/(D2:W2<>""),1))>C2)

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

Google Sheets - Set row number based from another cell value, inside the formula?

I would like to set the value of the row, from another cell
For example, this H186 cell, if I put a value in the cell A1, like 200, then the value would be H200
Something like this:
Assuming that A1 cell has a different value
=arrayformula(B2:B186&H2:H186) ===> =arrayformula(B2:B186&H2:H(A1))
Thanks in advance
You can create a string first in another cell and pass this cell from a dynamic range( Data > Named ranges in Menu).
example: you have Column A random numbers, in Column B you can pass any value in B1. In B2 string value and the formula cell, indirect function.

Resources