Lookup last non blank cell associated with a value - excel

I have a table with two columns, ID and Value. Each Value is associated with an ID. However, some Values are blank.
My table
ID Value
A2 102
A3 108
A4
A2 148
A3 91
A5 13
A3 Dog
A4 119
A5 58
A3
A4 Cat
A6
I want to look up the last non blank Value for each ID. I need this to work for all data types (numbers, strings, dates, etc). Also, some IDs may have no values at all. The formula should return "" for these.
Desired results below
ID Last Value
A2 148
A3 Dog
A4 Cat
A5 58
A6
What I've tried
=LOOKUP(9.99999999999999E+307,IF(A2:A12=D2,IF(ISNUMBER(B2:B12),B2:B12))) This works but only for numbers.
=LOOKUP(2,1/($A$2:$A$12=D2),$B$2:$B$12) Returns 0, which is the blank for A3.
=LOOKUP(2,1/(NOT(ISBLANK(B2:B12))),B2:B12) Returns 92, which is simply the last value.
=LOOKUP(2,1/($A$2:$A$12=D2),(NOT(ISBLANK($B$2:$B$12)))) Returns FALSE is there is a blank and TRUE is there are no blanks.
=LOOKUP(2,1/($A$2:$A$12=D2),NOT(ISBLANK($B$2:$B$12)),$B$2:$B$12) but the syntax is incorrect (too many arguments).

You can do something like this (as an array formula)

Related

if i put number 1 in cell C6 then -35 or if i put 2 in cell C6 then +35

I'm trying to add and minus the number from Cell E9 to display in Cell E8 e.g if i type number 1 in cell C6 then -35 or if i type number 2 in Cell C6 then +35 to the cell E9 to display in cell E8. Here is my formula below it works with number 1 but not with number 2.
=E9-IF(C6=1,35,IF(C6=2,+35))
Why does the formula don't work?
This should do the trick:
=E9-IF(C6=1,35,IF(C6=2,-35))
The issue is that your take - IF, so no matter what, both of your previous values would have get you a minus sign (- x + = -). (35 & +35 is the same)
There is a really good funcion in Excel "Evaluate Formula", that has step-to-step progress how the formula evaluate the calculation progress.
In our case you will see that the original formula would have progressed like this:
Original excel formula (typed 2 in C6):
0-IF(C6=1,35,IF(C6=2,35))
Next step, since cell C6 is 2, the first part of IF returns FALSE.
0-IF(FALSE,#N/A,IF(2=2,35))
Start evaluating next part (false part of IF, where 2=2 will be true)
0-IF(FALSE,#N/A,IF(TRUE,35))
The last part will give 35, but since you have minus:
0-IF(FALSE,#N/A,35)
You actually is arriving at the same number as the previous statement in the IF formula.
0-35
However,
if you set -35 in the last part IF(C6=2,-35) your final step will look like this:
0--35 -> 0+35

excel exclude a certain value from mode average

I'm looking for a formula that can find the Mode Average from a range of cells but exclude the value 14 from the range
example
A1 =26
A2 =14
A3 =14
A4 =14
A5 =26
A6 =3
A7 =16
A8 =16
A9 =26
Result would be:26 and not 14
Array formulas to the rescue:
=MODE(IF(A1:A6 <> 14,A1:A6))
Enter it via Ctrl + Shft + Enter
Not very elegant, but it works:
=(SUM(C3:C11)-COUNTIF(C3:C11,14)*14)/(COUNT(C3:C11)-COUNTIF(C3:C11,14))
c3:c11 is the range I am looking at on my test sheet.
I am basically looking for the sum of all values in the considered range, subtract 14 times the occurence of the number 14 from this sum and then divide the result by the total number of cells minus the occurences of 14 again. The whole thing will look much nicer, if you have the luxury of another cell that could serve as the "14-counter".
Edit: I overlooked the word "mode" in the question. This answer will only compute the average ...

Sum fields in a column if there is an entry in a corresponding row in another column

Assume the following data:
| A B C
--+------------------------
1 | 2 3 5
2 | 2 3
3 | 4 4
4 | 2 3
5 | 5 6
In cell A6, I want Excel to add cells C1, C2, C3 on the basis that A1, A2 and A3 have data in. Similarly, I want B6 to add together C1, C4 and C5 because B1, B4 and B5 have data.
Can someone help?
In A6 enter:
=SUMPRODUCT(($C1:$C5)*(A1:A5<>""))
and then copy to B6:
A simple SUMIF formula will work
=SUMIF(A$1:A$5,"<>",$C$1:$C$5)
Place that formula is cell A6 and then copy it to B6.
You can create another column, e.g. AValue, with the formula =IF(ISBLANK(A1),0,A1) in it. This will return 0 if the cell in A in the corresponding line is empty, or the value from the cell in A otherwise.
Then you can just sum up the values of the new column.

How read values from certain cells in a spreadsheet beyond VLOOKUP?

I have report with ID and values in columns. Values are determined 'TRUE' in column. Do you know how make report with two column with ID and value, for e.g.
At the top is the original report and at the bottom of the expected effect.
How macro to write. This is a simple example, in the future I'll have a more rows with ID and handiwork will be impossible...
Thanks for help!
In your simple example, use the formula =MATCH(TRUE,B2:F2) in B12
In this more generic example
Key 101 102 103 104 105
A1 TRUE
A2 TRUE
A3 TRUE
A4 TRUE
A5 TRUE
A6 TRUE
A7 TRUE
A8 TRUE
Key Val
A1 105
A3 102
A8 105
A5 103
A6 101
A7 105
, I used
=INDEX($1:$1,1,MATCH(TRUE,OFFSET($1:$1,MATCH(A12,A$2!:A$9),0)))
Use the below formula in cell B13, then drag it down to the rest :)
=MATCH(TRUE,INDIRECT(CONCATENATE(MATCH(A13,$A$1:$A$8,0),":",CONCATENATE(MATCH(A13,$A$1:$A$8,0))),TRUE),0)-1

Find text in column one and copy value from next column to column 3 in Excel [duplicate]

This question already has answers here:
Check if Cell value exists in Column, and then get the value of the NEXT Cell
(3 answers)
Closed 8 years ago.
Column 1 in my spread sheet contains text (just 1 word), 2nd column numbers and column 3 will have those numbers in specific order.
Example:
cell values
A3 aaaa
A4 bbbb
A5 cccc
A6 dddd
A7 eeee
A8 ffff
B3 11
B4 22
B5 33
B6 44
B7 55
B8 66
I want cell C3 to search the whole column A for a word ffff and once it found it, it would copy a value of the cell next to it in column B. So if the word ffff was in cell A8 the cell C3 would be 66 as B8=66. If ffff was in A5 than C3 would be 33 etc. After that I want C4 to find a word cccc in column A and copy value from next cell in column B and so on. Does anyone know how can I do it? Can this be done without using macros?
You can use VLOOKUP function, e.g. in C3
=VLOOKUP("ffff",A:B,2,FALSE)
the 2 tells Excel to return the value from column 2 of the specified range (A:B) and FALSE means that only exact matches are considered - see Excel help for more on VLOOKUP

Resources