How to write the offset's reference in excel? - ms-office

The cell d2 contains a number ,suppose it is 4.
I want to set the offset's reference as a5.
"a"&text(d2+1,0) can express string a5,i want to call data in range from a5 until a9.
OFFSET("a"&text(d2+1,0),0,0,5,1)
Why offset function in excel can't accept "a"&text(d2+1,0) as a5?
How to fix the offset function expression in excel?

use the INDIRECT function if you want to convert a string into a reference,
INDIRECT(ref_text, [a1])
so in your example:
OFFSET(INDIRECT("a"&text(d2+1,0)),0,0,5,1)
see https://support.office.com/en-us/article/indirect-function-474b3a3a-8a26-4f44-b491-92b6306fa261 for more details
However given offset takes,... offsets! you could just have a1 as the base and use the 4 to actually specify an offset., ie
OFFSET(a1,d2,0,5,1)

Related

How to get current Cell position of an Excel sheet using Apache POI

Is there any way to calculate or is there any built-in API to get the current Cell position of an Excel sheet using Apache Poi??
Like A10 or F61 or AG34 or BK567 etc.
Note: I'm using poi3.9.jar. Thanks in advance. It would be preferable if there's a built-in api.
I need this cell position because, I want to use the below Formula to set value.
Formula is : cell.setCellFormula("G16/F16*100");
If you have the Apache POI Cell object to hand, you can call cell.getAddress() to get a CellAddress object.
From that, you can cell formatAsString to get the cell's address eg A1
int colNum = 2; // eg
Cell cell = row.getCell(colNum);
CellAddress addr = cell.getAddress();
String asExcel = addr.formatAsString(); // eg C3

Including tab name in formula from cell

Similarly to this thread I have found Click here...
I am trying to create various formulae looking across tabs with the tab names kept in cells. My hyperlink function has been successful as:
=HYPERLINK("#'"&B2&"'!A1","Click Here")
Where B2 represents a 2-3 character tab name of a person's initials (e.g. AA in this example).
However if I try this method with other formulae I am returning a #VALUE! error. Can anyone help me with making this nested Index/Match function work dynamically from cell B1 rather than being fixed to the tab name "AA"?
=IF(OR(INDEX(AA!B:AH,MATCH(TODAY()-WEEKDAY(TODAY(),11)+1,AA!B:B,0),2)="",INDEX(AA!B:AH,MATCH(TODAY()-WEEKDAY(TODAY(),11)+1,AA!B:B,0),10)="",INDEX(AA!B:AH,MATCH(TODAY()-WEEKDAY(TODAY(),11)+1,AA!B:B,0),14)="",INDEX(AA!B:AH,MATCH(TODAY()-WEEKDAY(TODAY(),11)+1,AA!B:B,0),22)=""),"No","Yes")
Thanks in advance?
Dan
The hyperlink function accepts a constructed string to use as the link and interprets it as a range address just as it would a true url. A formula cannot accept a constructed string address as a worksheet range reference but the INDIRECT function converts constructed strings to a usable worksheet range reference.
INDEX(AA!B:AH,MATCH(TODAY()-WEEKDAY(TODAY(),11)+1,AA!B:B,0),2)
... becomes,
INDEX(indirect(text(B2, "'#'!\B\:\H")), MATCH(TODAY()-WEEKDAY(TODAY(), 11)+1, indirect(text(B2, "'#'!\B\:\B")), 0), 2)
With AA in B2, text(B2, "'#'!\B\:\H") becomes 'AA'!B:H. I find it easier to take care of the wrapping ' marks with a format mask.

Accounting/currency symbols extraction using formula in excel

I have a column in excel which contains data in multiple accounting format.
e.g.
USD 25
INR 140
CNY 74
in the formula bar it shows only the value and not the symbol. could you please help me to get formula to extract these symbols from cell. I dont want to run VBA code or create user function.
With the below user defined function you get the value as a text including the currency symbol:
Function GetTextValue(ByVal arg As Range) As String
'//Cell value (or top left cell value if range is more than one cell)
GetTextValue = arg.Cells(1, 1).Text
End Function
With a substitute you might replace the value and get only the currency:
=SUBSTITUTE(C2;TEXT(B2;"#.##0,00");"")
..
Use Text Function to get the cell formatting.
=Text(A1,"CopyPasteA1CellFormattingHere")
Change A1 to your desired cell reference.

Calling the same cell of different worksheets in EXCEL

I have a drop down list (with name of sheets) and based on that value, let's say that I select the Sheet4 as in the image, I want to bring to another sheet the value of that selection, let's say on the cell B8.
I know that this works:
=IF(B1="Sheet1", Sheet1!B8, IF(B1="Sheet2", Sheet2!B8, Sheet3!B8))
That's for just 3 sheets but is there a nicer or more efficient way to do this?
This is in general how all the sheets look like:
Use INDIRECT to construct a valid worksheet and cell reference from text-that-looks-like-a-worksheet-and-cell-reference 1
The indirect takes a string and turns it into a valid reference.
=INDIRECT("'" & B1 & "'!B8")
So in the case above it would create a string "'Sheet4!B8". Then the Indirect will turn it into a valid cell reference.
As Jeeped also pointed out in the comments The B8 reference since it is literal text it will not change if the formula is copied or dragged to another cell.
The B1 which is a cell reference and is relative will change as it is copied or dragged to different cells.
1 as per #Jeeped comment

How to refer the value of a cell in excel into a formula

I want to use the value of a cell in a reference formula.
For example:
I have a sheet with name '815108' which has all the data I need.
Now in the sheet1(new sheet), in A1 I type in ='815108'!A3 which gets the data from A3 in the sheet '815108'.
But the question I have -
In my new sheet 815108 is a defined attribute (For example: SO = 815108 is defined in cell F5.)
Instead of using '815108'!A3 I want to use the location in the current sheet. I tried ='=F5'!A3 which doesn't work. Any help is appreciated.
Thank you.
This is one of the few times that the INDIRECT should be used:
=INDIRECT("'" & F5 & "'!A3")
INDIRECT is a volatile function that translates a string into a viable reference.
Being volatile it will re-calculate every time Excel re-calculates regardless if the data to which it refers has changed or not.

Resources