+ Reply to Thread
Results 1 to 14 of 14

how to select only matching columns in excel

  1. #1
    Forum Contributor
    Join Date
    04-09-2013
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    176

    how to select only matching columns in excel

    Hi to all
    Good Afternoon
    I have example data like this, but in original data i have columns more 1200
    ID SNP1 SNP2 SNP3 SNP4 SNP5 SNP6 SNP7 SNP8
    1 A/A T/T T/G A/G MISSING T/T MISSING T/T
    2 A/A A/A T/G G/G G/G MISSING MISSING T/G

    now i would like to select ONLY columns containing any combinations of these A/T,A/G,A/C,T/A,T/G,T/C,G/A,G/T,/G/C,C/A,C/T,C/G, MISSING either in ID 1 or ID2 i.e. to select below columns only
    SNP1
    SNP3
    SNP4
    SNP5
    SNP6
    SNP7
    SNP8
    can any one help me with formula to find solution to my problem, any help in this regard will be highly appreciated
    Thanks in advance
    Regards
    Genetist
    Attached Files Attached Files

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: how to select only matching columns in excel

    Explain why SNP1 should be extracted?

    What is your CURRENT Excel version?
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: how to select only matching columns in excel

    No reply...

    Simplest approach is using a helper row (here row 6):
    =SUM(MMULT(IFERROR((SEARCH(TRANSPOSE($N$1:$N$12),B4:B5)>0)+0,0),(ROW($N$1:$N$12)>0)+0))

    and then, in A9, copied down:
    =IFERROR(INDEX($3:$3,AGGREGATE(15,6,COLUMN($B3:$I3)/($B$6:$I$6>0),ROWS(A$9:A9))),"")

    You seem to be using an older version of Excel than me. So, please refer to the attached file. If the HELPER ROW formulae are enclosed within a pair of { }, these are array formulae.

    These are a little different from ordinary formulae in that they MUST be confirmed in the FIRST CELL ONLY by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. After that, the array can be dragged down as normal, to cover the desired range.

    You will know the array is active when you see the curly brackets { } appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    04-09-2013
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    176

    Re: how to select only matching columns in excel

    Dear Glenn
    Good Afternoon
    Thanks for your help. I need to extract SNP1 and other matching snps to use in my experiment.

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: how to select only matching columns in excel

    That is NOT what I asked. How does it meet your criteria?

  6. #6
    Forum Contributor
    Join Date
    04-09-2013
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    176

    Re: how to select only matching columns in excel

    I would like to select columns which are having these A/T A/G A/C T/A T/G T/C G/A G/T G/C C/A C/G Missing either in ID1 or ID2 and at the same i want to select columns having same text like A/A in ID1 and A/A in ID2 and rest of the columns i will ignore.
    I hope i explained well
    Thanks for your help

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: how to select only matching columns in excel

    So... that is a new requirement. It was not mentioned in your original post. Is that correct?

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: how to select only matching columns in excel

    Why is column 1 included???
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: how to select only matching columns in excel

    No reply...

    change the helper to:

    =SUM(MMULT(IFERROR((SEARCH(TRANSPOSE($N$1:$N$12),B4:B5)>0)+0,0),(ROW($N$1:$N$12)>0)+0))+IF(SUM(--EXACT(B4:B5,B4))>1,1,0)
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    04-09-2013
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    176

    Re: how to select only matching columns in excel

    Glenn
    Its not new requirement but it is to select needed columns in another approach but in opposite way to my original request but both will give same solution.

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: how to select only matching columns in excel

    See my last post, which has a possible solution. However, it was NOT mentioned in the first post: A/A (or entire column matching) was not mentioned anywhere.

  12. #12
    Forum Contributor
    Join Date
    04-09-2013
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    176

    Re: how to select only matching columns in excel

    Dear Ali
    I would like to select columns which are having these A/T, A/G, A/C, T/A, T/G, T/C, G/A, G/T, G/C, C/A, C/G, Missing either in ID1 or ID2 and at the same i want to select columns having same text like A/A in ID1 and A/A in ID2 and rest of the columns i will ignore from my final solution
    Thanking you

  13. #13
    Forum Contributor
    Join Date
    04-09-2013
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    176

    Re: how to select only matching columns in excel

    Dear Glenn
    Good Afternoon
    Thanks for your help and time to provide solution to me. Apology for not explaining things clearly. Now your solution is working perfectly as expected

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: how to select only matching columns in excel

    No problem. You're welcome!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. New to excel - need help matching columns
    By ew-it in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 01-04-2019, 09:42 AM
  2. Find a partially matching text in excel columns
    By manjunathR in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-10-2017, 05:25 AM
  3. Formula for matching a column in excel to two other columns
    By hmoayyed in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-09-2017, 11:54 AM
  4. Replies: 1
    Last Post: 03-07-2016, 08:07 PM
  5. [SOLVED] VB code...Validation select to delete matching...Excel 2003
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-16-2012, 01:09 PM
  6. Replies: 7
    Last Post: 10-02-2009, 05:43 AM
  7. Req help matching values across columns in Excel
    By Richard B in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-07-2006, 03:35 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1