Get Excel cell relative reference into a cell - excel

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.

Related

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

Excel formula reference cell above last cell in range

I'm trying to set up a formula to automatically calculate the % change between the most recently added cell in a range (which includes #N/A values at the bottom of the range) and the cell immediately above it. I've been using this formula to obtain the value of the bottom not #N/A cell:
LOOKUP(2, 1/NOT(ISNA(G8:G19)), G8:G19)
Which is working fine. My first thought on how to reach the cell above it was to use OFFSET, like so:
OFFSET(LOOKUP(2, 1/NOT(ISNA(G8:G19)), G8:G19), -1, 0)
but this gives me an error, I think because the lookup function is returning the value in the cell rather than the cell reference. How should I format a function to return the value of the cell above the last non-N/A cell in a range?
Try this alternative for seeking the last non-error, numerical value in column G.
=index(G:G, match(1e99, G:G))/index(G:G, match(1e99, G:G)-1)
Using MATCH to find the last number in a column returns the row number to INDEX. It is a simple matter to subtract 1 from a row number.
One method is to use this array formula:
=INDEX($G$8:$G$19,MATCH(2,IF(NOT(ISNA($G$8:$G$19)),1))-1)
Being an array formula it must be confirmed with Ctrl-Shift-Enter on exiting edit mode instead of enter. If done properly then Excel will put {} around the formula.

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.

Comparing cells with using Excel LEFT Function

I wanted to compare value in cell A1 and B1.
However, sometimes PC give different value as cell B1.
Initial code I've been writing is as below in cell C1:
=IF(ISERROR(MATCH(A1,$B$1:$B$5,0)),"","Duplicate")
This code only compare exact value. Thus, I'm trying to add LEFT Function into function above:
=IF(ISERROR(MATCH(Left(A1,8),$B$1:$B$5,0)),"","Duplicate")
But above function only count character in A1 only. How do I add LEFT(B1,8) to also read value in cell B1?
Thanks.
Regards,
Zaiem
Maybe what you would like is:
=IF(MAX(IFERROR(FIND(LEFT(A$1,8),B$1:B$5),""))=1,"Duplicate","")
entered with Ctrl+Shift+Enter

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