+ Reply to Thread
Results 1 to 4 of 4

Request for VBA code to compare loumns to rows

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

    Request for VBA code to compare loumns to rows

    I have data in 6 columns
    1.First I want to find how many columns (from AB1 to AB5) are different for P1 and P2 ,
    Eq means: Both P1 and P2 should contain same letters (alleles) or if any one of P1 or P2 contains Z/Z or -/- I should consider them as eq only. Now I am doing this using this formula =IF(D2=D3,"EQ",IF(OR(D2="Z/Z",D2="-/-"),"EQ",IF(OR(D3="Z/Z",D3="-/-"),"EQ","NE")))

    2.I will compare lines column values from 1 with P2 across all the columns (from AB1 to AB5) in horizontal way and continue for remaining lines from 2 to 5. if they match I would like to give 1 else 0 and I would like to continue this till my programme encounters second set of P1 and P2. Presently I am doing this with this formula =if(D4=D$3,1,0).

    3. I will make sum for lines 1 to 5 across all the columns from columns AB1 to AB5, but I will include only columns showing different for P1 and P2 in my sum count. Now I am working on this with sumif formula.

    4.I will calculate percentage of matching lines 1 to 5 with P2 by dividing sum came from SUMIF with number of different markers between P1 and P2.
    5. I want to repeat this for remaining set of P1 and P2.
    I am expecting like this
    LINES XY1 XY2 XY3 XY4 XY5
    P1 EQ NE EQ EQ EQ SUM %
    P2 1
    1 0 0 1 0 0 0 0
    2 0 1 0 0 1 1 100
    3 0 0 0 0 1 0 0
    4 1 0 0 0 0 0 0
    5 1 1 0 0 0 1 100

    Like this I have data in more than 5000 rows and at present I am doing in excel 2010 with different formulas but it is taking lot of my energy. If anyone provide VBA code for this task I will be more happy and it would be Highly appreciated. I am attaching sample data for better understanding.
    Thanking you
    Regards,
    Genetist.
    Attached Files Attached Files

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Request for VBA code to compare loumns to rows

    Genetist,

    Could you please elaborate on point 3 - your existing calculation appears neither in the narrative nor attachment.

    Points 1 & 2 can (and 5) can be encapsulated in one formula, e.g:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The above will generate same results as in your sample file (cols G:K)

    I suspect we can do the remaining points within one formula which will resolve maintenance issues -i.e. one formula for all cells simultaneously.

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

    Re: Request for VBA code to compare loumns to rows

    Hi Dear DonkeyOte,
    Thank you very much for your reply and sorry for my late reply to your question. In my third and forth point everything same instead of countif formula i mentioned sumif there in my 3rd and 4th point by mistque. now my 3rd and 4th points will lookslike this
    3. I will make sum for lines 1 to 5 across all the columns from columns AB1 to AB5, but I will include only columns showing different for P1 and P2 in my sum count. Now I am working on this with countif formula.

    4.I will calculate percentage of matching lines 1 to 5 with P2 by dividing sum came from sumif with number of different markers between P1 and P2 came from countif.
    Thanks
    Last edited by genetist; 10-04-2013 at 05:23 AM.

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

    Re: Request for VBA code to compare loumns to rows

    Dear DonkeyOte,

    can you please eloborate your formula i am sorry i did not understand what 250 means and how it influences my calculation if i changes that value to some other value?
    Thank you very much

+ 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. request newton raphson code
    By hamidciv in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-02-2012, 03:34 PM
  2. [SOLVED] Request help in automatic registration code
    By hazem122 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-21-2012, 01:44 PM
  3. Round up/down - VBA code request
    By niravrph in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-14-2011, 09:15 AM
  4. Request Directory From User - VBA Code
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-02-2006, 02:00 AM
  5. [SOLVED] CF in VB Code - Simple Request
    By Kevin Baker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-02-2005, 08:06 AM

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