Include a range of cells for If/Then statement - excel

I have an IF statement that I want to have my 'true value' be true if (one of a range of cells values exist
=IF('Table Values'!C4='Table Values'!B84, 'Table Values'!C3, "<N/A>")
I want B84 to be B81 through B84
I tried
=IF('Table Values'!C4='Table Values'!B81:B84, 'Table Values'!C3, "<N/A>")
but that just shows #Value error in the cell
FYI - If this answer already exists tell me what my search criteria should have been to find my answer

Say we have happiness in cell A1 and we want to know if this can be found anywhere in column B. Use this formula:
=IF(ISNUMBER(MATCH(A1,B:B,0)),"Its there","no happiness")

Summarizing your question if in range B1:B4 there is the value in C4 you want to output C3. Please correct me if this is wrong. Based on this context, please consider the following formula:
{=IF(OR(C4=B81:B84),C3,"")}
Notice that the curly brackets represent that this formula is an array formula done by pressing CTRL + SHIFT + ENTER when inputting the formula. If you don't input it as an array formula it will only compare C84 with the top left most cell of the B81:B84 range (ie B81).
I can think of numerous other approaches to this, for example using a COUNTIF but I strived to follow your approach. Hope you find this useful. Cheers.

This gave me the closest solution, but now I have a problem expanding with the 'range' for other similar situations
=IF(ISNUMBER(MATCH('Table Values'!C4,'Table Values'!B84:B86)),"'Table Values'!C3"," ")
** Note: what is confusing to me about this is the 'isnumber', I am using 'text' not numbers, so that is why i did not consider it when i searched initially
And I now need to know how to use this for ranges with gaps
Example: instead of range B84:B86 I want my range to be B84:B86 and one other range C84:89.

Related

Syntax for Nested Excel Formula - SUMIF Where the Sum Range is a VLOOKUP Which has a Concatenation of Text and Cell Values to Makeup a Sheet Reference

I have a interesting puzzle going on which I believe is a syntax issue that has to do with the nesting of the formula in question. The reason I'm using such a funky formula is probably longwinded to the point of not being interesting, and certainly not useful to solving the issue I'm having. It would be possible to solve my issue without this formula but it would require a VBA project which isn't ideal for this use case. The formula is as follows:
=SUMIF('Sheet1'!$BR:$BR,'Sheet2'!$C19,CONCAT("'Sheet1'!",VLOOKUP(CONCAT($B$1," ",F$5),'Sheet3'!$J:$P,7,FALSE)))
Pulling the full formula apart, I have two formulas that work as expected:
Piece One: =SUMIF('Sheet1'!$BR:$BR,'Sheet2'!$C19,'Sheet1!'$AV:$AV)
Piece Two: =CONCAT("'Sheet1'!",VLOOKUP(CONCAT($B$1," ",F$5),'Sheet3'!$J:$P,7,FALSE))
Piece Two returns a value of 'Sheet1'!AV:AV and Piece One returns a value of 1,000,000 which is the correct SUMIF for the criteria I've set up in the formula. I've tried all sorts of combinations of ( and ) but continue to have Excel give me the message of either Your formula is missing a open or close parenthesis or Did you mean for this to be a formula? When starting a cell with a = or -.....
I'm trying to get the nested formula to resolve the "Part Two" first, so that when the entire nested formula evaluates it would solve "Part Two" which would leave me with an identical formula to "Part One" which would result in the 1,000,000 answer.
What am I missing here? Thanks in advance - this one's got me stumped!
Excel will not by default interpret your string as a range reference. You need to pass it to INDIRECT so as to be interpreted as such:
=SUMIF(
Sheet1!$BR:$BR,
Sheet2!$C19,
INDIRECT(
CONCAT("'Sheet1'!", VLOOKUP(CONCAT($B$1, " ", F$5), Sheet3!$J:$P, 7, FALSE))
)
)
Piece Two returns a value of 'Sheet1'!$AV:$AV
Piece Two in this case returns a string value, that happens to say 'Sheet1'!$AV:$AV. What you need piece two to return is not a text string, but a reference (or 'link') to the range on the sheet that is called 'Sheet1'!$AV:$AV.
To convert a string to a range reference you use the INDIRECT() function.
So your new formula is
SUMIF('Sheet1'!$BR:$BR,'Sheet2'!$C19,INDIRECT(CONCAT("'Sheet1'!",VLOOKUP(CONCAT($B$1," ",F$5),'Sheet3'!$J:$P,7,FALSE))))

Unable to use SUBSTITUTE(ADDRESS(MATCH))) combination as a range in a LOOKUP function in Excel

I have an Excel sheet containing a matrix of [Year & Week number] in rows and [name of Employees] in row1 giving values of available weekly hours.
I am able to successfully use the Excel formula
=LOOKUP(2,1/((A:A=2018)*(B:B=31)),D:D)
at cell F2 for a reverse lookup. It gives the result 15 correctly.
However, I wanted to replace range D:D in the above formula to a dynamic range by identifying the column when the employee is known.
So I tried replacing by the formula
SUBSTITUTE(ADDRESS(1,MATCH("Employee2",1:1,0),4),"1","") &":"&SUBSTITUTE(ADDRESS(1,MATCH("Employee2",1:1,0),4),"1","")
This portion of the formula works and gives D:D for Employee2. This is shown to work in cell F4.
But the revised formula gives an error of #Value! at cell F6.
It says "A value used in the formula is of the wrong data type."
The revised formula which does not work is:
=LOOKUP(2,1/((A:A=2018)*(B:B=31)),SUBSTITUTE(ADDRESS(1,MATCH("Employee2",1:1,0),4),"1","") &":"&SUBSTITUTE(ADDRESS(1,MATCH("Employee2",1:1,0),4),"1",""))
I hope someone can help show me where I am making an error in trying to replace range D:D in the LOOKUP formula with the combination of SUBSTITUTE, ADDRESS & MATCH functions.
Thanks to all trying to help in advance.
You cannot just plug a string, which is what SUBSTITUTE returns into a formula.
You can use INDERICT to turn the string into a viable reference:
INDIRECT(SUBSTITUTE(ADDRESS(1,MATCH("Employee2",1:1,0),4),"1","") &":"&SUBSTITUTE(ADDRESS(1,MATCH("Employee2",1:1,0),4),"1",""))
But both INDIRECT and ADDRESS are volatile.
Use instead INDEX to return the correct column:
INDEX(A:AAA,0,MATCH("Employee2",1:1,0))
So your formula is:
=LOOKUP(2,1/((A:A=2018)*(B:B=31)),INDEX(A:AAA,0,MATCH("Employee2",1:1,0)))

Equation for determining if a range contains one or more #N/A values

I'm developing a financial model and as a completeness check, I need to provide the user with a completeness check that essentially ensures that a range of data does not have any #N/A errors. For example, I'd like the equation in J1 to return "Incomplete" if a single cell in the range A1:A80 has an #N/A value and "Complete" if not a single cell has an error. Any ideas?
Try the following
=COUNTIF(A1:A80,"#N/A")
So
=IF(COUNTIF(A1:A80,"#N/A")>0,"incomplete","Complete")
Though sounds like you want something more broad like:
=IF(SUMPRODUCT(--(ISERROR(A1:A80)))>0,"Incomplete","Complete")
For dynamic range try:
=IF(SUMPRODUCT(--(ISERROR(OFFSET(A1,0,0,COUNTA(A:A),1))))>0,"Incomplete","Complete")
To count #N/A's specifically you can always use something like:
=COUNTIF(A1:A80,VLOOKUP(,,,))
EDIT#1:
This formula relies on a tiny trick, you see this formula:
=VLOOKUP(,,,)
returns a #N/A. We deliberately create an error to count a specific type of error. Another example:
=COUNTIF(A1:A80,0/0)
will count cells with #DIV/0! in them.
(It is equally easy to count cells containing #REF! or #VALUE!)
If you don't need a count, then array enter the formula =OR(ISNA(SomeRange)). Array Enter means type the formula in the formula bar, and push Ctrl Shift Enter
If you want it to return a message, use something like =IF(OR(ISNA(SomeRange)),"Complete", "Incomplete")
If you do need a count, then use =COUNTIF(SomeRange,NA())

How do I Count cells in excel, starting with a cell that has a specified value?

The question is slightly confusing, so I will do my best to elaborate. I have a series of cells in a row with all of the cells in the row with a value of 0 and one cell having a value of 1. I want to use the COUNT function to count all of the cells to the right of the cell that contains the value of 1, including that cell. I would then use this number of counted cells in another equation. Does anyone have any suggestions on how to do this? I have tried using a lookup function inside of the count function, but it has not worked. This is my closest guess:
=COUNT(Lookup(1,A1:J1):J1)
This results in an error. Do I need to use VBA to make this work or should I be able to write an equation? I appreciate the help, or if there are any other strategies that I can use to attain the result I am looking for.
Edit: I am adding in some sample data and expected results. I am trying to count all of the cells to the right of the "1" including the cell containing the "1". So in this example, I would expect the formula to return "13" as there are 12 cells to the right of the "1"
You can use OFFSET() and MATCH():
That last "50" is a bit of a guess since I'm not sure how far to the right you want to count...
...and re-reading your question it's not clear if you only want to count values of 1 or if you also need to count other values as long as they're to the right of the first 1.
With data in A1 through J1, consider:
=10-MATCH(1,A1:J1,0)+1
In this case. 4 is the number of cells from G1 through J1, inclusive.
Assuming your range of 0 and 1 values is in row 2, starting from column B, use this formula in B3 and copy it across for as far as you need:
=IFERROR(COUNT($B2:B2)+1-MATCH(1,$B2:B2,0),0)
You could also use a formula of
=IF(A3>0,1+A3,IF(B2=1,1,0))
but that could cause issues if you have something in cell A3 itself.
You can use this formula:
=COUNTA(INDEX($A$1:$J$1,1,MATCH(1,$A$1:$J$1,0)):INDEX($A$1:$J$1,1,10))
The benefit to use this is it is not a volatile function, and it will also work for 1 appears in the last column.
You can use "COUNTIF" formula to count number of occurrences of specific number in a range of cells.
To count no of occurrences in a row.
=COUNTIF(1:1,1)
If it is in a column then
=COUNTIF(A:A,1)
Hope you are looking for a countif function.
COUNTIF(A1:A10, 1)
The above function counts the cell that has value 1 within the range A1:A10

Excel: find the Max of an array with same names

I have searched the Net and tried multiple solution which never worked. You are my last hope.
I have a table like that:
NAMES.......... VALUES
A...........................4
A...........................1
B...........................4
B...........................3
B...........................2
B...........................1
C...........................4
C...........................3
As you can see, the first column has names only where the second one values.
Both Names and Values often repeat them self.
The idea is to TAG the names (first column) with the MIN value taken from the second column.
So the correct result should be:
NAMES.......... VALUES
A...........................1
B...........................1
C...........................3
I am trying to do that through Excel using the INDEX+Match formula where I am trying to add a MIN formula without success:
=MIN(INDEX($D$25:$D$36,MATCH(C25,$C$25:$C$36,0),1))
I have put the MIN everywhere but none seems to work. Which is the correct syntax and if this is not the right solution, which formula might do the job?
Thank you for your time and help
With data in column A and B, in C1 through C3 enter:ABC then in D1 enter the array formula:
=MIN(IF(A$1:A$100=C1,B$1:B$100,""))
and copy down:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.
If the data never changes, a Pivot Table is easier to implement.
Two non-array alternatives.
With the newer MINIFS function.
=minifs(d:d, c:c, c25)
Using INDEX in its array format but entered as a standard formula,
=min(index((d$25:d$36)+(c$25:c$36<>c25)*1e99, , ))

Resources