How to populate a particular cell value between two columns in Excel? - excel

I am facing problem to populate a cell value.
For example i have two columns A and B as shown below
A B
381 369
382 370.3
384 370.3
385 371
386 372
My aim is to get the respective value of column B value 370.3 as 382.
I tried using Vlookup formula "=VLOOKUP(D3,A:B,2,TRUE)"
Please help me to find the correct code to get the solution as in the image

If you wish to find "370.3" ie the contents of cell D3 then you will need to match in column B and index in column A so:
=INDEX(A1:A6,MATCH(D3,B1:B6,0))
VLOOKUP will not work as it indexes the leftmost column... or you change the data order.

Related

Excel same multiple values match same multiple values

Can I obtain G column in table 2 with formula?
More clearly, search first 155 in A column and write first match, search second 155 in a column and write secont match...

Calculate standard deviation of same text values between cells in same column

The last few days I have been trying to create a macro in Excel which can calculate standard deviation which will take values from column B of same text values between different cells in column A and give the result in corresponding cell in column C. In my sheet there are lots of different text values in column A and corresponding value in column B. I want to take all values of column B from first row to last row of corresponding same text in column A and calculate the standard deviation of these values and shows the result in column C.
As an example, when it starts from first cell (aass) then it has to count all aass and take values from corresponding cell of column B after that calculate standard deviation. Please help me out.I will be happy to hear from you guys. I am trying to show how my sheet which will look like as below:
column A column B column C
text value result(standard deviation)
aass 112 35.16
aadd 243 12.9
ffdd 523 108.55
aass 198 35.16
aadd 252 12.9
aass 136 35.16
ffdd 342 108.55
ffdd 312 108.55
aadd 222 12.9
aadd 255 12.9
ffdd 322 108.55
aass 112 35.16
jjhgf 487 25.8
pouwe 565 6
jjhgf 451 25.8
jjhgf 424 25.8
qwert 643 0
pouwe 553 5
qwert 643 0
..... .... ...
..... .... ...
This is what I used without VBA. This is an array formula (entered using Ctrl+Shift+Enter) which resides in cell C1:
=STDEV(IF($A$1:$A$9=A1,$B$1:$B$9))
(In in my example file I have only 9 rows of data.)
In newer versions of Excel you can use this:
=STDEV.S(IF($A$1:$A$9=A1,$B$1:$B$9))
For the entire population use this:
=STDEVP(IF($A$1:$A$9=A1,$B$1:$B$9))
or
=STDEV.P(IF($A$1:$A$9=A1,$B$1:$B$9))
The following versions will be MUCH SLOWER:
=STDEV(IF(A:A=A1,B:B)) , =STDEV.S(IF(A:A=A1,B:B)) ,
=STDEVP(IF(A:A=A1,B:B)) , =STDEV.P(IF(A:A=A1,B:B)).
I will show you what I mean by a Table with structured references.
I copied your data for the text and value columns. I also added the header: Result to cell C1.
I then selected the Table option from the Insert ribbon (on the Tables tab)
I then entered this formula in C2 as an array formula, confirming it by holding down ctrl+shift while hitting Enter
=STDEVP(IF(Table1[[#This Row],[text]]=[text],[value],""))
Excel automagically copied that formula down to the last row and produced the requested results. If you now add a row, the table will extend (including the formula). You can also add columns with different formulas.
In the formula above, Table1[[#This Row],[text]] refers to the context of the text column only on the row containing the formula, and [text] by itself refers to the entire text column; [value] refers to the entire value column.
The autoextension, and the ability to use the actual column labels is a desireable feature of Excel tables and structured references. It is similar to having dynamic named ranges, but easier to implement.

Excel VLOOKUP or INDEX MATCH

Lets say I have 3 columns of data
AMOUNT(A) AMOUNT(B) INVOICE(C)
55 49 4541
47 47 1515
42 47 4478
86 12 9993
12 100 1224
5 44 1452
100 4287
99 4444
What I need to check to see if the value in column A matches a value in column B. If there is a match, it will return the value from column C in column D. Now this is easy with a VLOOKUP however I am dealing with 700+ lines and there are multiple amounts that match. INDEX(MATCH) could work but it only returns one value. Is this a VB only problem?
I.E Value 47 exists in column B twice so therefore column D would return both invoice numbers (1515 - 4478)
In VBA, the problem would be trivial as you have already correctly described the logic with the problem statement itself.
Using Excel functionality only, without VBA is the interesting problem. You need to do the following steps to achieve an output that looks like this...
The steps are as follows:
Pivot Table: Make a pivot-table from the Columns (B) and (C) with Rows Fields as (B) and (C) and the minimum of AMOUNT(B) as the Value field. (See Figure below)
Helper Columns: Make a column on the side of the pivot table, say (Q) which is simply equal to everything in column (P)
Contd ... : In column (R) (which unfortunately happens to be in the sheet's column Q, sorry for the confusion there), as shown, for cell Q20 for e.g. put in the formula
=IF(P21=P20,Q21&","&M20,M20)
That will result in the creation of something like the table below:
Table:
(P) (Q)
12 9993
44 1452
47 4478,1515
47 4478
49 4541
99 4444
100 4287,1224
100 4287
Now the hard work is done. All you need to do is to lookup using VLOOKUP key-value pairs from this helper table (P)(Q)
- It will be very fast because the pivot table always keeps it sorted and hence an exact LOOKUP is not necessary.
- Screenshots are shown below for the Pivot table as well as for the final VLOOKUP formula
Pivot Table and Helper Table:
Final Formula:
so I'm using the Countif to see if there are dups based on column A.
In the D column type, =IF(COUNTIF($A$2:$A$9,B2)>0,C2,"")

Excel multi-column averages

I need to take the value in two data columns A and C, get a percentage by dividing the current value of columns A and C by the top value (which is a total), and then average the two percentages and spit them out in column D. For example D2 should be (100(226/508)+(100(218/490))) / 2). I'd prefer to do this with one equation - is it possible?
A B C D
1 508 490
2 226 44.49% 218
3 229 45.08% 221
The formula you want is
=(100*A2/A$1 + 100 *C2/C$1)/2
and the select all of column D downwards and then edit->fill down
The relative reference A2 will change in each row to the new row but A$1 is an absolute reference and will stay as the value in row 1.
You can also do this with array formula that do the fill down for you. See MS article

Autofiltered List; cross-row formula

I have a large Autofiltered list (~600 rows), with some of the rows being summary rows that I want to use a UDF to display the lowest priority listed in any of the 'child' cells. I can pass to my formula the right cells, but they are no longer correct if the list is re-ordered in any way. Is there a way to give the formula the right cell and have it recognise that I want that row and only ever that row?
I can do it with a VLOOKUP to look at a hidden column that lists wether the 'child' row matches the right criteria, but with 600 rows and each parent row requiring about a dozen 'child' cells each, it's too slow.
Assuming you have data that looks like this:
Age Gender Priority
52 M 521
53 F 631
78 M 12
81 F 632
then if you wanted to get, say, the lowest priority for males, you could do something like:
={MIN(IF(B2:B5="M", C2:C5, 9999999999999999))}
Note: the {} brackets just indicate that you need to enter the formula as an array formula.
Not 100% sure that answers your question, but hopefully it helps point in a direction that works.

Resources