Get sub-range address from other sheet - google-sheets

In my other question, I can get the sub-range of a range by using INDIRECT and CELL: Calculate PRODUCT of a sub-range in a Google Sheets range
However, If I use the formula in another sheet, it will show #REF!:
Error
Function INDIRECT parameter 1 value is 'Sheet1!$I$2:Sheet1!$I$17'. It is not a valid cell/range reference.
I know that the format should be Sheet1!$I$2:$I$17 but I wonder how can I do that?
Example sheet: https://docs.google.com/spreadsheets/d/1byIjDzHZE6s5N1PcN9yvSeC51bm9NVVC1tc1gjQQLHA/edit#gid=462032657
It could be better if I can use named range for this.

Where you get this Sheet1!$I$17 you might enclose it in:
REGEXEXTRACT(..., "[^!]+$")
This will cut off sheet's name from the cell name.
But you've got a nice solution in that question where you can use OFFSET and forget about string manipulations for INDIRECT. And it will still work when you copy it to different sheet.

Here's a tidy little solution that i've left for you on Sheet1 in cell R9:
=ARRAYFORMULA(PRODUCT(B2:N21^((A2:A21<=R3)*(B1:N1=R4))))
Cheers!

Related

Google spreadsheet change a cell depending on what is written on another cell

In a cell I have a list of locations made with data validation. Example Budapest, Belgrade, Bucharest.
next to the cell I have formula that i have to change manually if i change the cell with the location, EX: =index( Budapest!I:I; max(if(Budapest!B:B=E127; row(Budapest!B:B)))), =index( Belgrade!I:I; max(if(Belgrade!B:B=E127; row(Belgrade!B:B))))...etc
Is it a way to change automatically the formula, for ex if I select the city Budapest the formula to change to Budapest.
I have tried: =if(F127="Budapest"index( Budapest!I:I; max(if(Budapest!B:B=E127; row(Budapest!B:B))))) if(f127="Belgrade"index(Belgrade!F:F; max(if(Belgrade!B:B=E127; row(Belgrade!B:B)))))
if A1 = Bucharest (or whatever else) use:
=INDEX(INDIRECT(A1&"!I:I"); MAX(IF(INDIRECT(A1&"!B:B")=E127; ROW(INDIRECT(A1&"!B:B")))))
Depending on where the input data is will determine what the best formula to use it. But to be vague, the answer is yes. It will most likely require you to use a formula that pulls data and instead of the putting in a location of where to pull from, put a cell reference. Some formulas wont let you use a cell’s contents to reference a location. In that case you can concatenate the string from a cell into the formula. Here is an example of concatenation within a formula that does not allow cell references (query select where).
=QUERY('tab1'!$A$4:$R, "select * where A = '"&$C$5&"'")
It pulls all data where column A matches whatever value is typed into cell C5.
I understand this formula does not match your data but it provides an explanation of the mechanism of how to do so. I hope it helps. If not, please provide an example sheet and I can create a specific formula for your situation.

How can I SUMIF with horizontal and vertical criteria (including dates)?

I'm trying to SUMIF data based on two criteria:
The title of the column (horizontal)
In between two dates (vertical)
I have tried a number of functions to solve this problem but to no avail.
I have tried functions with Match, Index, and Filter, but I couldn't make the function work.
As you can see in my code, I have found a workaround, but it is not ideal as it does not use the table header to identify the data values I'm looking for (see example function below for Product A).
=SUMIFS(B:B,A:A,">="&A$2,A:A,"<="&A$5)
I'm hoping for a function that can dynamically grab the values I'm looking for, based on the table header and the dates.
Thank you for any help you may provide.
You can also use index/match to select just the relevant column of the range (where a zero in the row parameter indicates the entire column):
=sumifs(index($B2:$D,0,match(F1,$B1:$D1,0)),$A2:$A,">="&$A2,$A2:$A,"<="&$A5)
=ARRAYFORMULA({B1:D1; TRANSPOSE(MMULT(
TRANSPOSE(FILTER(B2:D, A2:A>=A3, A2:A<=A5)),
TRANSPOSE(SPLIT(REPT(10,
COUNTA(FILTER(B2:B, A2:A>=A3, A2:A<=A5))), 1))^0))})
My Data
Summary Required :
enter image description here
Formula : =SUMIFS(INDIRECT("C"& MATCH(B15,$B$2:$B$10,0)+1 & ":" & "G"& MATCH(B15,$B$2:$B$10,0)+1),$C$1:$G$1,">="&DATE(2022,2,1),$C$1:$G$1,"<="&DATE(2022,2,28))

How to make a relative reference in an array formula in Google Sheets

Here's the straightforward version of my question:
I want to change the following formula to an array formula...
Original formula (from cell J2):
=if(F4="VM:",G4,J1)
My attempt at converting to an array formula (in cell K1):
=arrayformula(if(row(A:A)=1,G3,if(F:F = "VM:",G:G,indirect("K"&row(A:A)-1))))
This works on rows where F = "VM:", but returns a #REF error on other rows. Function INDIRECT parameter 1 value is 'K0'. It is not a valid cell/range reference.
Thoughts on how to fix this?
The more complex version of my question. i.e. Why am I trying to do this?...
I have a weird spreadsheet with data that should really be in a Wiki.
I want to create filter views for each person so they can easily filter on only their own vendors. The original formula will work, but as more vendors are added, I'd like for the formula to automatically work for those rows as well.
If there's a better way to do this, I'm listening.
I don't exactly understand your needs, but If you want to autopopulate your formula, then you only need this code in desire column in row 4 (you can change this to any other - this will autofill down from this point):
=ArrayFormula(if(F4:F="VM:",G4:G,J1:J))
Is this what you are trying to get?
After clarification:
You need this code in J2 only:
=ArrayFormula(VLOOKUP(ROW(J2:J),
QUERY({F:G,ROW(G:G)},"select Col3,Col2 where Col1='VM:'",1)
,2,1)
)
Works for you?
maybe you just need to hide errors?
=IFERROR(ARRAYFORMULA(IF(ROW(A:A)=1,G3,IF(F:F = "VM:",G:G,INDIRECT("K"&ROW(A:A)-1)))),)

How to return the cell next to the cell that contains a string in Google Sheets?

So say I have a google spreadsheet where:
A1 contains a string,
and I have a bunch of cells in Column D that contain strings.
There is a cell in column D that matches A1. Say it is D5.
My goal then, is to make a function that returns E5.
I tried using MATCH, but that returns the number in the array, rather than the cell address. Even if it did return the cell address, I'm not sure how I would use it to find the cell next to it. Optimally, I would like this address to be returned in a way that I can input into another function. So how can I do this?
Please tell me if I can make this question more clear in any way. I'm very tired right now, so it might be worded weirdly.
Thanks in advance!
VLOOKUP() is exactly what you need, if you need the cell value of E5.
=vlookup(A1, D:E, 2, 0)
If you need the cell's address, you are probably thinking about your problem wrong - what is it exactly you want to do with the cell address?
There are two functions, that will be handy in this case:
if you want to get value from E5 then use offset
if you need to get "E5" as string, then use address function.
Also if you have an address like "E5" you may get the value of E5 with indirect function.

VLOOKUP within IMPORTRANGE

I'm trying this function on Google spreadsheet without success in order to gather in a sheet a value after a VLOOKUP:
=importrange("otherurl";cell("address";vlookup(value("201608"),"All_nodevice!$A$16:$C$1000",2,false)))
I get a general error.
Does IMPORTRANGE support this kind of functionality?
What I need to do is to extract data from the cell of another sheet that has the value 201608 on its left. Since IMORTRANGE wants a cell pointer such as $A$12, I thought to do these steps:
search with a lookup the value.
convert the result in a cell pointer.
I found the right way. May be it could be useful for someone else.
=VLOOKUP(201608;IMPORTRANGE("sheet url"; "All_nodevice!$A$16:$C$1000"); 2; 0)
or
=query(IMPORTRANGE("sheet url";"All_nodevice!$A$16:$C$1000");"select Col2 where Col1=201608 limit 1")
Just the ID worked for me as well instead of the URL. I had my numbers as text, so kept getting an error at first. Silly mistake, but what you are looking up probably has to be the same kind of thing (text vs numbers).
=vlookup(Q6,IMPORTRANGE("1m9IN4_NH717VATXWLnPgTvrKxnRHwtH8z-f38r9F3zY","Props!A1:Bb400"),38,false)

Resources