Find Gene name in Column A and put the given ID in column B - excel

I have an excel Sheet with 2 columns, in this form
ADRBK2 NA
ADRBK2 NA
A1CF ID1
A2M ID2
ADRBK2 NA
Now what I want to achieve is that i look up the gene ADRBK2 in Column A and where ever i find this gene in Column A in my file, I want to put ID3 at the column B next to it. How can i Achieve this ?

Sort your data alphabetically, put ID3 in cell next to first ADRBK2, drag by left bottom corner of the ADRBK2 cell to the end of empty cells(simple copy).

Related

Closing row gaps in excel

I have the following in an excel spreadsheet:
A B C
1 ID Label Text
2 123 R Some text
3
4 456 S Some more text
5
6 789 R Even more text
But I want to close the row gaps so my excel spreadsheet can look like the following
A B C
1 ID Label Text
2 123 R Some text
3 456 S Some more text
4 789 R Even more text
5
6
I found the following https://www.extendoffice.com/documents/excel/511-merge-rows-keep-data.html but it is not quite what I am looking for
Question: Is there an automated/easier way to close the row gaps, aside from doing this manually?
(I can do this manually by cutting and pasting but my excel sheet contains thousands of rows that contain these sort of row gaps)
You could do an index match. In another column (say column D), simply do something like if(a3="", "", row()). Then in another column rank each row if there is a value. Something like if(d3="", "", rank(d3, $d$1:$d$6). Create another column (say column E) that just goes from 1 to the end of the data set (increment each row by 1). Finally do an index match like so: index(A:A, match(d3, $E:$E, 0).
Per Jeeped and tehhowch, the easiest way to accomplish the goal is to simply sort by column ID value

Excel: How to add a column from other sheet based on a key column?

I have 2 list. Both have a lot of column. I would like to insert a column from Sheet2 to Sheet1 based on a ceratin key column. Also sheet2 have much more rows than sheet1 so it ll be inserted only partly and still there ll be elements with no matches. For an example:
Sheet1:
Names ID Car Color
John 1 Audi Empty
Andy 4 Toyota Empty
Mike 3 BMW Empty
Tony 2 Suzuki Empty
Sheet2:
ID Cost Color
6 200 Blue
3 200 Red
4 300 Green
5 100 Red
1 50 Black
I would like to get the "color" from Sheet2 to Sheet1 by using the "ID". Using Excel 2010. I suspect I need INDEX+MATCH combination, but the examples I can find are not detailed and more simple so I coudn't figure out how to use them.
How about inserting this formula on Column D in the first row, then dropping the formula down:
=VLOOKUP(B1,Sheet2!$1:$1048576,3,FALSE)
Or to find the column that contains "Color", use Index Match Match, as follows:
=INDEX(Sheet2!$1:$1048576,MATCH(Sheet1!B2,Sheet2!A:A,0),MATCH("Color",Sheet2!$1:$1,0))
This will find the value in Column B in Sheet2 and give you the row number, then it will find the Column that contains "Color" and return the Column number, with those two numbers Index will return your color.

Excel if vaules of 2 columns match then take the difference of another two columns

I have 4 columns of data. I want to match the values of two of the columns then if take the difference of two other columns if the first two match. So it's accounts and amounts.
Example. If col A matches Col C take the difference of Col B and Col D and Out it in Col E
Col A Col B Col C Col D Col E
1234 $100 1234 $100 $0
1235 $120 1235 $150 $-30
1236 $150 1237 $150
1238 $130
=IF(A1=B1,C1-D1,)
A1 and B1 are cell references to values you are comparing, and C1 and D1 are cell references to the values you are trying to take the difference of. If you'd like to have the cell be blank instead of 0, add "" after the last comma.
Assuming first data row to be A2:E2, Please put below mentioned formula in cell E2
=IF(A2=C2,B2-D2)
Similarly you can do reverse action by like if it is not then add them or put 0 or blank by "" or subtract B2 from D2 by below given options.
=IF(A2=C2,B2-D2,B2+D2)
=IF(A2=C2,B2-D2,0)
=IF(A2=C2,B2-D2,"")
=IF(A2=C2,B2-D2,D2-B2)
Hope this would help!

Remove swapped duplicated row using Excel

I have an id pairs in 2 columns. There are some pairs which are redundant, but in a swapped form. How can i removed redundant id pairs using Excel?
Here is the explanation,
Initial,
col1 col2
id1 id2
id2 id1
id3 id8
id1 id5
id1 id6
id2 id9
Need to be like,
col1 col2
id1 id2
id3 id8
id1 id5
id1 id6
id2 id9
(Note that the 2nd row id2 id1 is deleted, because it is a swapped duplicate).
Thanks..
1.Write two max min functions in the as a excel function adjacent to these 2 cells(maxa did not work for some reason)
2.copy values only to some other place and remove duplicates.
ps: I tried to transpose then sort transpose back, but it tries to sort as one big record rather than tuples. Hence the function.
I would use the following steps:-
Join them together in the right order into column C
=IF(A2<B2,A2&"|"&B2,B2&"|"&A2)
Find the unique values in column D (array formula must be entered with Ctrl-Shift-Enter))
=IFERROR(INDEX($C$2:$C$7, MATCH(0, COUNTIF($D$1:D1, $C$2:$C$7), 0)),"")
Separate the first one in Column E
=IFERROR(LEFT(D2,FIND("|",D2)-1),"")
Separate the second one in column F
=IFERROR(RIGHT(D2,LEN(D2)-FIND("|",D2)),"")
Assuming you're dealing with Column A and B with a header in each column, I'd do this put cell C2 and drag down. Delete anything greater than 0:
=COUNTIFS($B$2:B2,A2,$A$2:A2,B2)
To clarify what's happening here, the $ in the ranges act as anchors when you drag down. So making the range from $B$2:B2 means the next cell down will be $B$2:B3 followed by $B$2:B4 and so on.
The COUNTIFS() formula returns a count where ALL the criteria are met, so only those rows with both values switched are counted.
Using the COUNTIFS() with the anchored range like I've done here only counts whatever comes above that row, which is why you can delete any non-zeros without losing the unique values.
I'd recommend verifying this in case there's something I didn't think of, of course.

Selecting a row in excel based on specific values in 2 columns,

Data roughly in the format
A B C
ID1 ID2 0.5
ID1 ID3 0.7
ID2 ID3 0.9
I want to create a correlation matrix (column C being the correlation between the IDs in A and B). It can definitely be done with a pivot table, though I have to use sum which could be risky if a duplicate existed since an error might not be apparent. Output format would be:
ID1 ID2 ID3
ID1 1 .5 .7
ID2 .5 1 .9
ID3 .7 .9 1
(the '1' is easily done with an =IF(B$2=$A3,1,0) and replacing 0 with the formula to find the correlation)
I basically want a match (col a= ID1 && col b = ID2). I suspect it could be done by concatenation, but I am not sure that is a great solution? Match/Vlookup etc only return the first match [in that column], which is no good to me. Ode to a 'where' clause I guess?
My searches did not reveal any usuable help, I have already calculated the correlation and am putting it into excel from SQL. So yeah, any ideas would be super, a pivot table being a last resort.
Thanks.
Assuming your source data range is on Sheet1, from A1 to C3 and your results range is on Sheet2, from A1 to D4.
You can put this formula on B2:
=SUMPRODUCT((Sheet1!$A$1:$A$3=Sheet2!B$1)*(Sheet1!$B$1:$B$3=Sheet2!$A2)*Sheet1!$C$1:$C$3)
and then, drag and drop this formula on the whole range.
Why don't you create a third column that combines the values from columns A and B using =A1&B1 and then do vlookup on that value:
A B C D
ID1 ID2 ID1ID2 0.5
ID1 ID3 ID1ID3 0.7
ID2 ID3 ID2ID3 0.9

Resources