Can I name a column a variable in google sheets? - google-sheets

Google sheets allows you to set a particular cell as variable so I can set A1=JimsHeight
But is there a way to name an entire column and use it as variable?
Then I might set A = height so that I can use height1, height2 to represent A1, A2 etc. in a formula?
UseCase is in order to be able to drag down a formula.

No, I might set A = height so that I can use height1, height2 to represent A1, A2 etc. in a formula? is not possible.
What you can do is giving height to the header (i.e. A1) of the column, then use for instance
=offset(height,2,)
for A3

You could do the following:
Add a named range for your column (see Name a range of cells):
Call INDEX on the named range to get your desired cell:
=INDEX(height,2)

Related

How to conditional format each row of a column based on corresponding value in another column

Please refer the image
I want the cell to be highlighted based on the value is less than or greater than the value in the benchmark column. I am not able to do that using conditional formatting custom formula. I have manually applied formatting for 02/01/2023 . I want the formatting to apply to the column with date = today() only.
Thanks :)
I can write a custom formula for each row of each date column. But is there any way a single custom formula that could format across rows and columns?
I'm guessing your fist value of 02/01/2023 and Activity1 is C2. Then for the whole range C2:Z (or whichever you have):
=C2>=$B2
Do this for one color for the whole range and it will drag automatically, you don't need to write it as an arrayformula. The "$" will always refer to the value in column B from the row it's positioned
if you are selecting whole range (C2:Z), try this for green and red respectively:
=(C2>=$B2)*(C2<>"")
=(C2<$B2)*(C2<>"")

GOOGLE SHEETS: Help needed to sum a range of cells across rows, where the range is controlled by a variable

I need to sum a range of cells across rows, but I need to be able to specify the amount with a variable.
For example.
If i write 5 in cell B1, I want to sum range A1:A5.
If i write 10 in cell B1, I want to sum range A1:A10.
If i write 20 in cell B1, I want to sum range A1:A20.
And so on.
Does anyone know a formula for this?
Kind regards.
I tried writing( in cell B1) =SUM(A1:A(1+B1)). This didn't work at all, instead a =NAME? appeared.
You may use INDIRECT to set a range by joining text, like this:
=SUM(INDIRECT("A1:A"&B1))
This formula will also work:
=SUM(BYROW(SEQUENCE(B1),LAMBDA(ROW,INDEX(A1:A,ROW))))
SEQUENCE() return an array of rows count up from 1 by default.
BYROW() can use an array as row reference and apply a LAMBDA() function to each row.
INDEX() return the CELL the matches a given INDEX of ROW and COL.
SUM sum up every value of a range (array).
also possibility:
=SUM(A1:INDEX(A:A; B1))
or:
=SUMPRODUCT(A1:INDEX(A:A; B1))

How to use value from one cell into another cell's "Conditional format rules "

I'm trying to set Conditional format rule on cell Y1 based on value of cell X1.
e.g. If Y1 cell value > value in X1 then set particular color.
But I am not getting which formula to use to get value from X1 cell
Simply use =X1 with the format rule greater than:
The important point is to to use = to indicate that you are refering to a cell in the spreadsheet.
See also Use conditional formatting rules in Google Sheets
you can try like this:
=Y1>X1

VlookUp: can I reference the range to a cell value

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)

Reference a cell using formula?

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

Resources