Google Sheets how to reference one cell based on another cell - google-sheets

I am working on a nutrition spreadsheet.
The columns (in row 13) are 'Calories' 'Carbs' 'Protein' and 'Fat'.
Under each of those cells (in row 13) are values that change.
Im trying to come up with a formula that searches for the maximum value in row 13 and returns the cell reference of the cell above it.
Ive tried combinations of:
lookup
hlookup
match
max
address
index
cell
Some times it would return 'Fat' when the Calorie column had the max value.
Other times it would say it couldn't find a value within the array, that was clearly there...

Figured it out. Index(,,Match(Max(),,))

Related

Find range of last used cell in row, calculate distance and offset to display cell contents of first cell in the found range's column

This may be an iterative of this question. This would be an easy VBA task, but I believe this is more than doable using formulae. I have a general idea of how to achieve this but may be overthinking, I'm sure there is a more elegant way to do this than what I have so far.
I have a row of dates in row 1 containing values such as "1/31/2021", "2/31/2021", and so on. Below this are text values -- some cells are blank, others have basic text like "abc123" (there will never be a scenario where there are blank cells between text cells, so false positives are not a concern). My goal is to find the range of the last used cell in a row, then display the cell contents of the first cell in that column to find an appropriate date. What I have so far manages to find the last used row, and I am able to use offset to display the appropriate date, but I am looking for a solution that is scaleable, so that the formula can be used in a series of descending rows and will always correctly calculate the distance between the last used cell in each row and the contents of the first row in the result's column.
Below is what I have to find the last used cell in a row:
=INDEX(2:2,MATCH("zzzz",2:2))
This is what I have to find the last used cell in a row and offset to the cell in row 1 in the found column. This works for just row 2 as the distance between row 2 and row 1 is known. It would be ideal to offset by a dynamic value to always find the first cell in the column:
=OFFSET(INDEX(2:2,MATCH("zzzz",2:2)),-1,0)
To find the first cell in the last column of a specific row:
=INDEX($1:$1,0,MATCH("zzzz",2:2))
This will return the value in row 1 in the last column with a value in row 2.

How to populate blanks in a column with last non-blank cell

I have a spreadsheet of data on Google Sheets where one order is spread over several rows, however, only the first row contains all the information. I need a way to copy the last populated cell down into all of the blanks.
So it looks like the left, but I need it to do what's on the right:
GB GB
- GB
AU AU
- AU
- AU
I've tried every formula I could find online, but they all either don't work or require pasting into every blank cell. This spreadsheet could reach 20,000+ rows, so I really need a formula that will do this automatically. I don't mind if it duplicates the whole column into a new column using an ARRAYFORMULA, I just need it to contain all the correct data.
To summarise, I want a formula that will take an entire column of a spreadsheet and populate every blank cell with the value in the last populated cell above it.
=ARRAYFORMULA(IF(ROW(A2:A) <= MAX(IF(NOT(ISBLANK(B2:B)), ROW(A2:A))),
VLOOKUP(ROW(A2:A), FILTER({ROW(A2:A), A2:A}, LEN(A2:A)), 2), ))
or remove NOT

Get new array from old array so nth cell represents the sum of all cells in old array up to its index n

I'm trying to get a one-dimensional new array from an old one, where the nth cell in the new array is the value of the sum of all values up to the nth cell in the old array. In the array that I already have the data in each cell represents the profits per day. And I would like to get a new array where each cell represents the accumulated net profit up to that day.
Some things I tried to do to come up with a solution:​​​​
https://docs.google.com/spreadsheets/d/1qpBFtW6r8oQF75htpLQDhL8IxejuM7vmKN8qHOn-5vY/edit?usp=sharing
=ArrayFormula(SUM( OFFSET($A$2,0,0,ROW(A2:A)-1,1)))
=A3:A+INDIRECT("B"&TO_TEXT(ROW()-1))
For the first formula needs to be applied to every single cell. Instead, I just want a formula for B2 that returns an array to generates all the values underneath it.
And the second formula makes google sheets too slow to use for me.
Any help would be appreciated.
=ARRAYFORMULA(IF(LEN(A2:A), (SUMIF(ROW(A2:A), "<="&ROW(A2:A), A2:A)), ))

Google Sheets show rows with multiple matching cells

I'm needing a formula that gives me the value of the "I" cell if other cells in the row match specific values.
For instance, based on the image I've linked below, if I looked for the results of rows where B=5, C=2, D=2, E=1, and H=F, it would give me the I cell values for rows 12 and 15 (3.03 and 3.63).
Maybe:
=QUERY(A:I,"SELECT I WHERE B=5 and C=2 and D=2 and E=1 and H='F'")
Untested as I can't be bothered to key in what you did not bother to provide as text.

How to return the number of blank cells in a column between entries

How may I return either an array address of blank cells in a column between entries, or count the number of blank cells until a column holds an entry in Google Sheets?
Counting from the top, the first occupied row number (therefore by deducting 1, the number of blank cells) before an occupied cell may be determined, for ColumnA with:
=ArrayFormula(MATCH(FALSE,ISBLANK(A:A),0))-1
Within a more detailed explanation there is an explanation of how the above works, in Excel, at Exceljet. The principle is the same for Google Sheets.

Resources