Use INDIRECT function on a Non Adjacent cell range - excel

Okay, so I can very easily use Indirect on a cell that contains a range(entered as text) and then use INDIRECT to reference that range :
Like it's done here (see Answer):
Have one cell represent a cell range
*In the column C there's a drop down list for each '=INDIRECT()'
The range E2:E4 'returns' to the drop down list : Miami,Paris,Rome
The range E5,E2 SHOULD give: Amsterdam,Miami but it gives #REF

If you are putting each value in a separate column then you can use the following:
=IF(ISBLANK(A2),INDIRECT(B2),INDIRECT(A2)&","&INDIRECT(B2))
This will return your original indirect if the cell is blank and if not it will return both values. (I used column A but you can change the reference

Related

Set Range based on Cell Value

In the Index and Match functions, the columns are fixed (column C for the index range and Column F for the Match range). The starting row for both is on a seperate page "Input" Cell C7 and ending row for both is on the same "Input" page but Cell C10. The ranges are on a sheet "Constants". The formula is on a sheet "Summary". The starting and ending rows will change project to project and I need a way for these formulas to update based on the row values on the "Input" page.
I think the issue is that the ranges as calculated are returned with quotation marks at the beginning and end. When I hard code the current ranges, the quotation marks aren't there. I tried the Substitute function to replace the quotations with nothing but they remained. I also tried using the Address function, but it returned with quotation marks too. An example input for B2 in the formula is P102. Input!C7 = 1271, Input!C10 = 1400. So the code is trying to return the value in Column C on the constants page by matching the row 102 is in in Column F.
=IF(OR(RIGHT(B3,2)="01",RIGHT(B3,2)="64"),"REFERENCE",INDEX("Constants!C"&Input!$C$7&":"&Input!$C$10,MATCH(NUMBERVALUE(RIGHT(Summary!B3,3)),"Constants!F"&Input!$C$7&":"&"F"&Input!$C$10,0)))
Wrap your references in the INDIRECT function. From the documentation:
Use INDIRECT when you want to change the reference to a cell within a formula without changing the formula itself.
INDIRECT("Constants!C"&Input!$C$7&":C"&Input!$C$10)...
and
INDIRECT("Constants!F"&Input!$C$7&":F"&Input!$C$10)...

Excel formula that combines MATCH, INDEX and OFFSET

I am having trouble with an Excel-function.
On sheet A I want to get the value of a cell that is located x-columns to the right of cell F2.
X is a variable number and is determined by the value of cell A1. Currently, the value is 5.
=(OFFSET(sheetA!F2,0,sheetA!A1))
This formula works. However, I want to include this function into a MATCH and INDEX function that is located on another sheet (B).
I know that I can use the following formula to get value of $F$2
INDEX(sheetA!F:F,MATCH(sheetB!C4,sheetA!A:A,0))
Combining them, results in the following formula:
=INDEX((OFFSET(sheetA!F2,0,sheetA!A1)),MATCH(sheetB!C4,sheetA!A:A,0))
This formula generates a #REF!-value.
If I evaluate the formula, I see the following steps:
=INDEX((OFFSET(sheetA!$F$2,0,5)),MATCH(sheetB!C4,sheetA!A:A,0))
=INDEX((sheetA!$K$2),MATCH(sheetB!C4,sheetA!A:A,0))
=INDEX((sheetA!$K$2),MATCH("BTC",sheetA!A:A,0))
=#REF!
Why do I want to use MATCH and INDEX?
Because while the values on sheet A are "fixed", the values of sheetB!C4 are floating/variable. Therefore, I need to locate the correct row first. The correct column can be done with the offset-part.
Thank you for your help.
Try this
=INDEX((OFFSET(SheetA!F:F,0,SheetA!A1)),MATCH(SheetB!C4,SheetA!A:A,0))
Syntax of INDEX is
INDEX(array, row_num, [column_num])
where, array is range of cells. When you use =INDEX((OFFSET(sheetA!F2,0,sheetA!A1)),MATCH(sheetB!C4,sheetA!A:A,0)), (OFFSET(sheetA!F2,0,sheetA!A1)) returns sheetA!$K$2 which is a cell not a range.

Countifs and ranges

I'm trying to write some code that requires a cell value to be within a range of dates.
This is what I have written so far (albeit a few name changes for simplicity):
=IF(COUNTIFS('[SheetA.xlsx]TabA'!A2:AA2, "submit", '[SheetA.xlsx]TabA'!B2:AB2, '[SheetA.xlsx]TabB'!**A9:A13**) >= 1, '[SheetA.xlsx]TabA'!C2, "")
Basically, if a cell in a row contains the word "submit" AND the cell to the right of it has a date (within a specific range of five days), I'd like the function to return the third cell of that row.
The range in bold is a range of dates.
This formula doesn't work when I use a range, but returns expected values when I enter a single date. What should I change?
As for COUNTIF() not finding a date in a range, if the range is consecutive, you can get around that like so:
COUNTIFS(A2:AA2, "submit", B2:AB2,">=" & LowestDate,B2:AB2,"<=" & HighestDate)
The problem there is that you're comparing a range to a range, so the whole range has to match the whole other range. This will always return false since the ranges are not even the same shape. When instead you compare a range to a single value, Excel automatically assumes you want true if the single value exists anywhere in the range.
It sounds like your other issue is that since COUNTIFS() does not return where it found "submit" and a date, the outer IF statement cannot determine where the third cell is.
If there's only going to be one submit, you could use Match("submit",2:2,0)+2 to find the relative column of "submit" add 2 to it, and then use ADDRESS() to build the address of the third cell based on the row. Last you put that inside of an INDIRECT() to return the third cell. Something like:
=INDIRECT(ADDRESS(ROW(A2),MATCH("submit",2:2,0)+2,1,1))
Note that this will not work for multiple matches as you're returning the first value MATCH() finds.
I use ROW() because ADDRESS() may not fill the row series very well when you drag the formula down a column if you use a plain row number.

use ADDRESS function to define range in COLUMN

I have to use
=COLUMN($L$1:$CA$1)
as part of my original formula that CA, is the last column for a table named MyTable.
Because the last column is always changing (add columns every month),
i want to use
=COLUMN($L$1:ADDRESS(1,COLUMNS(MyTable)))
but this is not work.
My question is: how can i add last column of a table to a part of specific range?
ADDRESS returns a string. But the range reference in COLUMN($L$1:...) needs a cell reference after the :. INDEX will return a cell reference.
So try within your formula:
...COLUMN($L$1:INDEX(MyTable,1,COLUMNS(MyTable)))...

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.

Resources