+ Reply to Thread
Results 1 to 8 of 8

Compare and Count Two Columns, Then Filter Out 100 and 0

Hybrid View

  1. #1
    Registered User
    Join Date
    01-28-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2016
    Posts
    17

    Compare and Count Two Columns, Then Filter Out 100 and 0

    Hello,

    I'm trying to find a way/formula to compare the values in MAR columns to FEB column and if they match to count them and not "100"and "0."

    These are percentage complete. Need to find the 'stagnant' ones.
    Can anyone help? Been trying CountIf(S). Can't get it to work.
    FEB MAR
    55 55
    0 0
    65 65
    95 95
    100 100
    100 100
    95 100
    0 0
    0 0
    100 100
    95 100
    55 55
    55 55
    55 55

    I should get a count of 6 with these numbers.

    TYIA,

    Patty

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Compare and Count Two Columns, Then Filter Out 100 and 0

    THere is probably a better way to do this with a formula. This is all I could come up with at the moment:

    Sub Count_Differences()
    Dim rCell As Range
    Dim iCount As Long
    
    iCount = 0
    
    For Each rCell In Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row)
        If rCell.Value <> "0" And rCell.Value <> "100" Then
            If rCell.Value <> rCell.Offset(0, 1).Value Then
                iCount = iCount + 1
            End If
        End If
    Next rCell
    
    MsgBox (iCount)
    
    End Sub

  3. #3
    Registered User
    Join Date
    01-28-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2016
    Posts
    17

    Re: Compare and Count Two Columns, Then Filter Out 100 and 0

    Thank you stnkynts.
    Can you tell me how I would call it out on the sheet?

    Patty

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Compare and Count Two Columns, Then Filter Out 100 and 0

    Can you tell me how I would call it out on the sheet?
    I don't understand what you mean. Are you asking how you would create a command button and assign the macro to it, how to assign a shortcut key to it, how to run a macro, or somthing else?

  5. #5
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Compare and Count Two Columns, Then Filter Out 100 and 0

    Can you tell me how I would call it out on the sheet?
    I don't understand what you mean. Are you asking how you would create a command button and assign the macro to it, how to assign a shortcut key to it, how to run a macro, or somthing else?

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Compare and Count Two Columns, Then Filter Out 100 and 0

    with a formula
    =SUMPRODUCT((A2:A15=B2:B15)*(A2:A15<>0)*(A2:A15<>100))
    or slightly shorter
    =SUMPRODUCT((A2:A15=B2:B15)*(MOD(A2:A15,100)<>0))
    Last edited by martindwilson; 03-18-2014 at 11:24 AM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  7. #7
    Registered User
    Join Date
    01-28-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2016
    Posts
    17

    Re: Compare and Count Two Columns, Then Filter Out 100 and 0

    Thanks you MARTINDWILSON!!
    It worked :D
    =SUMPRODUCT((D2:D1411=E2:E1411)*(MOD(D2:D1411,100)<>0))

    Thank you for your help as well stnkynts. I meant calling the sub out in a cell, =Count_Differences(????).

    Have a great day!
    Patty

  8. #8
    Registered User
    Join Date
    01-28-2013
    Location
    Houston, TX
    MS-Off Ver
    Excel 2016
    Posts
    17

    Re: Compare and Count Two Columns, Then Filter Out 100 and 0

    This is what I've been trying, doesn't work:

    =SUMPRODUCT((D2:D1411=E2:E1411)*1, --(E2:E1411,"<>"&0),--(E2:E1411,"<>"&100))

    they are columns D & E.

    I will try what you posted Martin, thank you.

    Patty

+ 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. How to compare two columns and filter results ?
    By ASP__DEVELOPER in forum Excel General
    Replies: 8
    Last Post: 04-17-2010, 11:00 PM
  2. Compare and count 2 columns
    By pictogram in forum Excel General
    Replies: 8
    Last Post: 01-29-2010, 06:07 PM
  3. compare columns and count number of matching columns
    By san000 in forum Excel General
    Replies: 1
    Last Post: 07-15-2009, 10:31 PM
  4. Compare and count 2 columns
    By svvm in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-24-2005, 09:02 AM
  5. Compare 2 Columns and get a count
    By hilton in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-18-2005, 11:02 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