Index match returning N/A when lookup value is null - excel

I have a summary sheet in a workbook that allows a user to enter in a 3 digit ID and some summary data and a chart populates. In the source data, the ID for the totals row is blank. So, when the lookup value is blank (no 3 digit ID is entered) I expected the Index Match formula to return the values corresponding to a blank cell in the lookup array, but it doesn't. How can I fix this?
Sampling of the data:
ID March April
111 10 15
222 15 10
333 10 10
35 35
Formula used:
=INDEX(B9:B12,MATCH(A1,A9:A12,0))
Where A1 is the lookup value

Say we have data like:
and we want to enter the name in A1 and retrieve the age in B1 and also accommodate the blank in column E.
In B1 enter:
=IF(A1="",INDEX(F:F,MATCH(TRUE,INDEX(ISBLANK(E1:E30),0,0),0)),VLOOKUP(A1,E2:F21,2,FALSE))

You cannot lookup a blank cell. Use IFERROR to find the first blank with AGGREGATE in the target if you receive an #N/A.
=INDEX(B9:B12, iferror(MATCH(A1,A9:A12,0), aggregate(15, 6, row($1:$4)/not(len(A9:A12)), 1)))
row($1:$4) is the position within B9:B12 that you are returning to the INDEX.

Related

Formula Help SUM Based on Given Value

i have data in Column A - Days and Column B - Sales i want calculate running total based on Days Value like
Column A Column B
Day1 150
Day2 200
Day3 175
Day4 250
i want total running sum in Column E Based on Value in Column D
here i applied this formula to running sum based on cell value
=SUM($B$2:B2,INDEX($B$2:B5,MATCH($D$2,$A$2:A5,0)))
here i have getting wrong result like if i enter (Day3 in Cell D2 getting result in Cell E2 - 325) it's wrong
The syntax is just a bit off, you should add up the range from B2 to the position found by the match, in this case B4:
=SUM($B$2:INDEX($B$2:$B$5,MATCH($D$2,$A$2:$A$5,0)))
This works because Index returns a reference and can be used as one end of a range.

Return row number from Excel sheet based on filters

I have the following excel file with two sheets namely Sheet1 and Sheet2. Sheet1 contains few names with repetitions like below.
Column E
-------- ----------
Row 3 tom
Row 4 jerry
Row 5 mick
Row 6 tom
Row 7 john
Row 8 mike
Row 9 mick
Row 10 eric
Row 11 matt
Row 12 mike
I want to be able to determine the row in which, for example, the second occurrence of the name "Pete" occurs. For this I have to set up a new worksheet (Sheet2) that will allow me to enter a person's name and a positive integer (such as n), and returns the row in which the name occurs for the nth time.**
Enter Name : tom (cell B1)
Enter Integer :
Result : `2`
For the result cell I have applied the below formula which is returning the no. of times the name occurs.
=COUNTIF(Sheet1!E3:E12,Sheet2!B1)
But I am not been able to find the desired answer.
Can it be done to with Countif, Countifs, Count, CountA, and CountBlank Functions?
Can anyone please help?
=AGGREGATE(15,6,1/(myRng=B1)*ROW(myRng),B2)
Explanation
myRng=B1 match each entry in myRng with the name in B1 giving an array of TRUE;FALSE
1/… changes that to an array of {DIV/0,1,... depending on whether it matches
*ROW(myRng) converts that to an array of {DIV/0, row_num}
AGGREGATE(15,6,resultant_array,B2) returns the nth smallest value from that array, ignoring the errors

How do I split a row of text into different columns according to number of characters using a macro in Microsoft Excel?

I want to know if I can use a macro in Excel to separate data in a single column into different colums according to number of characters. For example, what I have is this in column A
A
AB
ABC
1A
564
8
What I need is this, in colums A, B and C
A AB ABC
8 1A 564
Thanks.
Use the following formula in a new column B next to Column A:
=IFERROR(INDEX($A$1:$A$6,SMALL(IF(LEN($A$1:$A$6)=1,ROW($A$1:$A$6),99999),ROW()),1),"")
Array Formula press Ctrl+Shift+Enter at the same time
and drag it down, it will write the Values of B whose Length is 1, and when it gives empty it means no more Values with Length 1
Small will find the Cell which length is 1 (Row()=1, 1st cell which length=1, Row()=2, 2nd cell which length =1 ...)
If will return all the rows for the corresponding condition
Index will return the Cell
Iferror return empty "" if no more match
For the second column write 2 instead of 1 in LEN($A$1:$A$6)=2
=IFERROR(INDEX($A$1:$A$6,SMALL(IF(LEN($A$1:$A$6)=2,ROW($A$1:$A$6),99999),ROW()),1),"")
For the third column write 3 in LEN($A$1:$A$6)=3
=IFERROR(INDEX($A$1:$A$6,SMALL(IF(LEN($A$1:$A$6)=3,ROW($A$1:$A$6),99999),ROW()),1),"")

Logic behind last evaluation step of a LOOKUP formula to find last non empty value in a row.

I want to get last non empty cell from every row for further operations. Searching Net I came across a LOOKUP formula which can do this job fine. I have alpha as well as numeric data in the rows.
Sample Data is shown below.
ID1 ID2 ID3 ID4 ID5 ID6 ID7 ID8 ID9 ID10 ID11
a1 a2 a3 a4 a5 23 24 25 25
23 NN 67 99 200001 ss p1 23 rq 3
I am using the following formula in L4 which gives correct results that is 3 in L4. Similar formula for row 2 gives result of 25 in L2.
To understand the formula I carried out Formula Evaluation but I am not getting the logic of last step as how it translates to final result.
=LOOKUP(2,1/(A4:K4<>""),A4:K4)
LOOKUP(2,{1,1,1,1,1,1,1,1,1,#DIV/0!,1},A4:K4)
After this step result that is the last non empty value of Row 4 comes i.e. 3
Can someone explain how this line is finally translating into the result step by step.
Basically taking the below formula as an example
=LOOKUP(2,1/(A1:D1<>""),A1:D1)
With data in A1:D1
A1 B1 C1 D1
1 2 3
The formula will populate as follows
=LOOKUP(2,{1,1,1,#DIV/0!},{1,2,3,0})
The way this works is quite simple.
1/(A1:D1<>"") creates an array of 1's and #DIV\0!
1 where the cell is not blank
#DIV/0 where the cell is blank
Then the lookup formula looks for a 2 in this array , which it cant find, but it will always return the position of then last NON ERROR value in the context of an array filled with 1's and #DIV/0!, which would be the 3rd position in the array, The LOOKUP formula then returns the 3rd position of the last argument array in the formula A1:D1 , which is 3
This approach finding the last filled cell uses the vector form of LOOKUP. In
=LOOKUP(2,{1,1,1,1,1,1,1,1,1,#DIV/0!,1},A4:K4) the 2 is the lookup_value, the array {1,1,1,1,1,1,1,1,1,#DIV/0!,1} is the lookup_vector and the A4:K4 is the result_vector.
The vector form of LOOKUP looks in a lookup_vector for the lookup_value and returns the value from the same position in the result_vector.
If the LOOKUP function can't find the lookup_value directly in the lookup_vector, the function matches the largest value in lookup_vector that is less than or equal to lookup_value. If multiple equal values are in the array, which are the largest which are less than or equal to lookup_value, the position of the last is taken. In this case it matches the last 1 since this is the largest value in lookup_vector that is less than or equal to 2.
But for this to do, there is the rule, that the values in lookup_vector must be placed in ascending order. And this is the not documented feature with this approach. It seams as if the #DIV/0! errors within lookup_vector does not contradict that rule. But since the source is not open, we can't be absolutely sure about this. But this approach is used sucessfully so often, that we can be very sure.

Vllookup, match, index

I am trying to compare data from one sheet to another. Address and its ID.
Both sheets have Address and ID. ID can be repetitive.
Sheet 1 Sheet 2
Address ID Address ID
23 1 22 1
45 1 45 1
23 2 23 2
45 2 45 3
I want to check whether the data address & ID on sheet 1 appear on Sheet 2 thus making a new row with return Yes or No on sheet 1 for every column.
This can be done very quickly with an array formula.
Picture of ranges and result shows the data on the same sheet so that it is easier to see what is going on. Pretend Sheet1 is on the left and Sheet2 is on the right.
Formula in cell D3 is an array formula (enter with CTRL+SHIFT+ENTER) and then copied down to fill.
=(B3=$F$3:$F$6)*(C3=$G$3:$G$6)
This formula will simple return a 0 or 1 for no match/match. You can wrap it in an IF if you want text instead. It is simply checking that the relevant values match for both columns in both "sheets".

Resources