How to use Google Spreadsheet ADDRESS function to create a range - google-sheets

I'm trying yo create a formula in google spreadsheet that calculates the maximum value for all the cells above the current cell, in a way I can copy it to any cell and still workss. I tried using the ADDRESS function like this:
=MAX(ADDRESS(1;COLUMN()):ADDRESS(ROW()-1;COLUMN()))
But I get an parse error. I tried many variants of this code, but always get an error. Apparently, the ADDRESS function is not allowed as part of a range.
Is there any way to create a reference to a range based on the current cell position?

Was stuck on something very similar. Something like this should work.
=MAX(INDIRECT(1, COLUMN()) & ":" & ADDRESS(ROW()-1, COLUMN())))

This might be useful too if you want to get the sting address for a range:
=ADDRESS(row(A3:A6),COLUMN(A3:A6))&":"&ADDRESS(row(A3:A6)+rows(A3:A6)-1,COLUMN(A3:A6)+COLUMNS(A3:A6)-1)
This will return a string on the range, in this case
$A$3:$A$6

Using the INDIRECT function on your range string returns a range reference, which can then be used in a formula, eg.
INDIRECT(ADDRESS(1;COLUMN()):ADDRESS(ROW()-1;COLUMN()))
should work in
MAX(INDIRECT(ADDRESS(1;COLUMN()):ADDRESS(ROW()-1;COLUMN())))

Related

Get sub-range address from other sheet

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!

Conditional Formatting with 2 Sheets not working

im trying to mark matching URLs red.
I have two sheets with URL Data.
My custom Formula looks like this:
match(A2,indirect(Sheet2!A2:A),0)
wondering why there is an error if i use =match(A2,indirect(LostURLs!A2:A),0)
so with the additional =
Anyways both methods are not working and im wondering why?
Indirect excepts the first argument to be "a cell reference as string".
So please try
=match(A2,indirect("LostURLs!A2:A"),0)
and see if that works?
Note: depending on if you want the formatting for a single cell, a column or a row you may have to use a dollar sign in the first argument of the match() function
E.g: If you'd want to repeat the formatting for column A, you would have to use
=match($A2,indirect("LostURLs!A2:A"),0)
For row 2 that would be:
=match(A$2,indirect("LostURLs!A2:A"),0)
and for a single cell
=match($A$2,indirect("LostURLs!A2:A"),0)
NOTE: Depending on your locale, you may have to change the comma's to semi-colons.
perhaps try:
=MATCH(A2; INDIRECT("LostURLs!A2:A"); 0)

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