Excel function reference specific cell and all cells below - excel

I am trying to write a function in excel that references a range from specific cell in a column, in this example A22 or B22 to the last cell in that column. Something like this:
=MAX(IF('Sheet1'!$A$22:$A$LAST="YES",'Sheet1'!$B$22:$B$LAST))
How do I accomplish this?

Or........
=LOOKUP(1,0/(A:A="YES"),B:B)

Replace the end reference with INDEX MATCH
=MAX(IF('Sheet1'!$A$22:INDEX('Sheet1'!$A:$A,MATCH(1E+99,'Sheet1'!$B:$B))="YES",'Sheet1'!$B$22:INDEX('Sheet1'!$B:$B,MATCH(1E+99,'Sheet1'!$B:$B))))
Remember to confirm with Ctrl-Shift-Enter.

Related

VBA if value in cell display string in other cell

I'm trying to set some things in my Excel in order to improve my process.
I would like to create a VBA function which let to display value in cell B13 if cell B11 contains "_01_Clients_Particuliers" and cell B12 contains "_00".
These cells are dropdown list.
I never use VBA up to now.
I could write into the cell B13 :
=IF(COUNTIF(B11,"_01_Clients_Particuliers"),"_100PRD05","")
But I need to take into account two cells and I assume I need to use VBA to do that, because the cell B14 has already a formula : =INDIRECT(B13)
Do you have any idea ?
Assuming you drop-down list only contain few selection, then the following formula should be work for you.
=IF(AND(ISNUMBER(SEARCH(H1,C1)),ISNUMBER(SEARCH(H2,C2))),"It is there","not found")
In addition, you will write the range reference directly, it will return error in my case
Unless I've misunderstood your question, I don't think you need VBA to do this.
Check out Using IF with AND, OR and NOT functions
Again, apologies if I'm mistaken, but it seems that your desired result could be produced with the following formula in B13:
IF(AND(B11 = "_01_Clients_Particuliers", B12 = "_00"), "_100PRD05","")
This will put the value "_100PRD05" in B13 if B11 equals "_01_Clients_Particuliers" and B12 equals "_00".

Get Excel cell relative reference into a cell

I am trying to find how to get an excel formula to get a cell's relative reference into a cell.
A formula that would be like =getcellreference(B2) and then has B2 as the output.
Nothing complicated but i could not find a simple solution.
You can use CELL():
=CELL("address",B2)
For formatting to literally show B2 instead of the absolute reference, you can do:
=SUBSTITUTE(CELL("address",B2),"$","")
If all you are trying to do is output a cell reference that you manually input, then all you need to do is:
="B2"
or
B2 (no equals sign)
You can use the ADDRESS function to obtain the address of a cell in a worksheet, given specified row and column numbers
ADDRESS(row_num, column_num, [abs_num], [a1], [sheet_text])
So for cell B2, you will need to put =ADDRESS(2,2) where the first 2 stands for the row number and 2nd is for column B.

Autofill by next column over with indirect formula

I was wondering why the formula I did won't go to the next column over. I did place the $ sign to stay in the same row, but not on the column, thinking it will go to the next column over. Is there any suggestions as to why this is doing this?
The following is the formula I inputted into the spreadsheet:
=(INDIRECT("BHR8732A2!P$16"))*$S283
Because you have " " around the sheet and cell reference BHR8732A2!P$16, it's going to be treated as a text string, not a cell reference. It's not going to change when you copy across.
If you want to just multiply the value in column S by the value in row 16, you'd write it as ='BHR8732A2'!P$16*$S283.
If you want to multiply the value in column S by the value in another cell whose address is in row 16, you'd write it as =INDIRECT('BHR8732A2'!P$16)*$S283.
Using a text string inside the Indirect is kind of the 'worst of both worlds', where you're just feeding the cell reference directly into the Indirect, which is unnecessary.
I'm not sure why the whole BHR8732A2!P$16 has quotes. Excel does not seem to recognise the P$16 part as a cell reference for me.
Try this: =(INDIRECT('BHR8732A2'!P$16))*$S283

Formula works in excel, but name does not

I have this formula in excel, to return a row number:
=MATCH(INDIRECT(ADDRESS(ROW(),4)),DayOffRequests!$A$1:$A$100,0)
and it works just fine.
I would like to make a new name (DAYS_OFF_ROW) and assign it to this formula.
Here's what I did in the name manager:
But when I write this into a cell: =DAYS_OFF_ROW it says #VALUE! whereas when I write the same formula into the cell, it gives me the row number I am looking for.
Why is does it say #VALUE! and not the row number like the formula does?
First off Row() returns the row on which the cell resides. If you put Row() in indirect you will get an error since there is no cell for which Excel can find a Row(). So right off the bat, your formula is nonsense for a named range.
Second, even if there was some magic way for Excel to know which Row() you cared about here, Match doesn't return a range. Just a position in an array like "5" or "50". When you use a formula to define a named range, the result of the formula MUST be a range. So you could do another Indirect like =Indirect("A" & Match(foo,bar)) or something so that the result out of your formula actually refers to a range in your sheet.
It works if i set the name to this formula: =MATCH(!$D1,DayOffRequests!$A$1:$A$100,0)
Of course i have to be in field A1 when setting the name. Now its reference the fourth column and whichever row i am in.

Use string value from a cell to access worksheet of same name

I have 2 worksheets: Summary and SERVER-ONE.
In cell A5 on the Summary worksheet, I have added the value SERVER-ONE.
Next to it, in cell B5, I would like a formula that uses the value in A5 to display the value of G7 in the worksheet of the same name (SERVER-ONE).
I could manually use:
='SERVER-ONE'!G7
However I would like this to be dynamic, so I can easily add more worksheets.
I tried the obvious with no joy:
='A5'!G7
Any suggestions?
You can use the formula INDIRECT().
This basically takes a string and treats it as a reference. In your case, you would use:
=INDIRECT("'"&A5&"'!G7")
The double quotes are to show that what's inside are strings, and only A5 here is a reference.
You need INDIRECT function:
=INDIRECT("'"&A5&"'!G7")
not sure if you solved your question, but I found this worked to increment the row number upon dragging.
= INDIRECT("'"&$A$5&"'!$G"&7+B1)
Where B1 refers to an index number, starting at 0.
So if you copy-drag both the index cell and the cell with the indirect formula, you'll increment the indirect.
You could probably create a more elegant counter with the Index function too.
Hope this helps.
Here is a solution using INDIRECT, which if you drag the formula, it will pick up different cells from the target sheet accordingly. It uses R1C1 notation and is not limited to working only on columns A-Z.
=INDIRECT("'"&$A$5&"'!R"&ROW()&"C"&COLUMN(),FALSE)
This version picks up the value from the target cell corresponding to the cell where the formula is placed. For example, if you place the formula in 'Summary'!B5 then it will pick up the value from 'SERVER-ONE'!B5, not 'SERVER-ONE'!G7 as specified in the original question. But you could easily add in offsets to the row and column to achieve the desired mapping in any case.
By using the ROW() function I can drag this formula vertically. It can also be dragged horizontally since there is no $ before the D.
= INDIRECT("'"&D$2&"'!$B"&ROW())
My layout has sheet names as column headers (B2, C2, D2, etc.) and maps multiple row values from Column B in each sheet.
INDIRECT is the function you want to use. Like so:
=INDIRECT("'"&A5&"'!G7")
With INDIRECT you can build your formula as a text string.
Guess #user3010492 tested it but I used this with fixed cell A5 --> $A$5 and fixed element of G7 --> $G7
=INDIRECT("'"&$A$5&"'!$G7")
Also works nested nicely in other formula if you enclose it in brackets.
This will only work to column Z, but you can drag this horizontally and vertically.
=INDIRECT("'"&$D$2&"'!"&CHAR((COLUMN()+64))&ROW())

Resources