VlookUp: can I reference the range to a cell value - google-sheets

I am using Google Docs and unfortunately it does not have a GetPivotData function. As I add more categories and subcategories to my data, the Pivot Table data will be moving (column wise).
So I took the liberty to use formulas and find the Row and Column numbers for all my ranges, so regardless of any new data, my range will expand/contract/shift with the correct data.
Now all I have left is to use a VLOOKUP to feed the data for that specific subcategory. I have a cell that shows the value for my range.... my range is D7:S100... but like I said, if I add one more subcategory, then my range will be D7:T100 and my cell will reflect this change. I want to use this cell reference in my VLOOKUP so it can be dynamic in the range.
VLOOKUP(search_key, range, index, [is_sorted])
VLOOKUP(A1, cell reference, 2, 0)
Can the range ever be a cell reference so my vlookup's range be dynamic?

Use a Named Range. This is available in Google Spreadsheets from the Data menu.
Create a named range to represent your table of data.
Give it a name like myTable or whatever you want to call it, then you can use that Name in the formula:
=VLOOKUP("BOB",myTable,2)
If you need to expand the range, just go back in to the Named Range menu and edit the existing range.
I have not tested it yet but if this is like Excel, then you can even define a named range based on a formula (typically using the Offset, COUNTA, Index and some other functions to dynamically determine the size of the range). This is probably available to Google Spreadsheets but I have only done that in Excel.

Can the range ever be a cell reference so my vlookup's range be
dynamic?
There may be better ways of achieving what you need to do, but the short answer is yes - using INDIRECT.
B1: D7:T100
=VLOOKUP(A1,INDIRECT(B1),2,0)

Related

Conditional Formatting on Google Sheets with Named Ranges

I've searched a bit for this issue and maybe I can get help here.
I'm trying to apply a conditional formatting through a named range and I only figured out that "Indirect" plays an huge role on this.
This is the typical table I'm working on, Heading, plus every row has a name with some notes. The table has a named range (Let's call it "Table") assigned to A1:D7 because I have some scripts on GAS that sort the list in different ways based on button pressing.
Since the table is updated pretty often, I just add rows to the "Table" Named range, so the script works fine.
Under the table the typical conditional formatting I use to color the zero or negative cells of both the column B and C but not the column D
Now what I have to do is to apply the whole conditional formatting on only the named range (but just the columns B and C).
I could "Apply to the range" B:C (So I don't have to change it) but under the table there are some other numeric data that I don't want to format.
Using a custom formula =INDIRECT("Table")<=0
doesn't work either since the table has the column Name, plus with some arrangements it colors both the cells B* and C* if the B value is negative and the C is not.
I'll probably add some more stuff since I'm working on it but if someone could aid just on this it would be very helpful
Browsing a bit and understanding that the Conditional formatting just cycle every cell in the range applied and uses the custom formula to check if it should format it or not, I should put it the fact that the cell has to be inside the named range as a condition.
I found this to be useful on a "B2:C" range =AND(NOT(ISERROR(INDEX(INDIRECT("Table"),ROW(B2),COLUMN(B2)))),*condition1_on_B2*,*condition2_on_B2*,*etc*)
(found it on the second post here on this link)
The first conditions returns true when the cell is not inside the named range
NOT to reverse the ISERROR value
ISERROR will return true if INDEX throws an error which is only when the cell is outside the named range
INDEX will attempt to find the cell B2 (or the cell the conditional formatting is checking on every iteration) inside the named range.
It probably is very heavy, performance-wise but for now it works, if there is something else, I'll wait for a better answer.

define range of all but last of occupied cells in a column

How can I define a range in Google Sheets to match all but the last occupied cell in a column? ie if column A is blank after A45, say, I want the range A1:A44. I have explored various constructs to find the row of the last occupied cell, eg
=ARRAYFORMULA(MAX(ROW(A:A)*(A:A<>"")))
How can I define the required range?
take:
=INDEX(INDIRECT("A1:A"&MAX(ROW(A:A)*(A:A<>"")))

Sum range with dynamic row on google sheet column

I'm trying to sum a trying column,
I need the row in the range to be dynamic
I have tried
=sum($B$9:CONCAT("B", ROW()))
and then drag it but I'm getting an error,
I also tried with the address and it didn't work
Spreadsheets have a simple way to express this sort of thing: absolute and relative references. Try this in cell C9:
=sum(B$9:B9)
Then drag down the formula cell to extend it to additional rows.

How would I alternate row colors whenever a value changes in any column?

I'm trying to get Google Sheets to alternate row colors whenever any cell in the row is different from the cell above it (within a specified range).For instance:
I found a few related solutions (this one for example), but they all base the alternation on only one column's changes; the MATCH function only applies to a one-dimensional range.
Is there any way to accomplish this with multiple columns?
=ARRAYFORMULA(ISODD(MATCH($A2&$B2&$C2&$D2,UNIQUE($A$2:$A&$B$2:$B&$C$2:$C&$D$2:$D),0)))

Using the same formula for each row in sheet

I want for every row in my sheet to calculate a score using a formula. So the same formula for each row. I tried this:
=ARRAYFORMULA(min((((C3:C100)/4)+((K3:K100)*4/10)+(M3:M100)+((N3:N100)/2.5)+((O3:O100)/5)+(R3:R100)+(T3:T100)+((P3:P100)/3)+(V3:V100))/23))
But it does calculate at all, for any row. (I am starting from row 3)
Why does it act like this? Any suggestions?
It's always best to provide us a link to your sheet, so we can see what you're trying to accomplish (or at least create a copy without sensitive data and share that).
If you want the same exact formula for each row, you will get the same exact result with your current formula. Also, do you mean to SUM the range values you have provided inside the formula? If so, you need to alter your formula to look like this:
=ARRAYFORMULA(min((((sum(C3:C100)/4)+(sum(K3:K100)*4/10)+sum(M3:M100)+(sum(N3:N100)/2.5)+(sum(O3:O100)/5)+sum(R3:R100)+sum(T3:T100)+(sum(P3:P100)/3)+SUM(V3:V100))/23)))
Please be more specific about exactly what you want the formula to calculate on each row. If it's on row 20, for example, do you still want rows 3-100 to be considered? Or just rows 20-100? WHAT data do you need to be considered on each row's formula, in other words?
Here's a sheet I created to try to understand what you want:
https://docs.google.com/spreadsheets/d/1GRdU6NLMWx2xPXDNp21VzYRQRj6cjNbL4RGVUV2x8Wk/edit?usp=sharing

Resources