+ Reply to Thread
Results 1 to 15 of 15

count unique records in one column based on criteria in a different column

Hybrid View

  1. #1
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: count unique records in one column based on criteria in a different column

    Maybe:

    Sub rxg2669()
    Dim i As Long
    Dim ws As Worksheet
    Set ws = ActiveSheet
    Sheets.Add.Name = "Name Count"
    ws.Activate
    For i = Range("A" & Rows.Count).End(3).Row To 2 Step -1
        If Range("A" & i).Value <> Range("A" & i + 1).Value Then
        Sheets("Name Count").Range("A" & Rows.Count).End(3)(2) = Range("A" & i).Value
        Rows(i + 1).Insert
        End If
    Next i
    Range("B2").Select
    zz:
    If ActiveCell.Offset(2) = "" Then
    ws.Range("A2:A" & ws.Range("A" & Rows.Count).End(3).Row).SpecialCells(4).EntireRow.Delete
    Exit Sub
    End If
            x = 0
            Do Until ActiveCell.Value = ""
                If Cells(ActiveCell.Row, "B") <> Cells(ActiveCell.Row + 1, "B") Then x = x + 1
                ActiveCell.Offset(1).Select
            Loop
            Sheets("Name Count").Range("B" & Rows.Count).End(3)(2) = x
            If ActiveCell.Value = "" And ActiveCell.Offset(1) <> "" Then ActiveCell.Offset(1).Select
            GoTo zz
      
    End Sub

  2. #2
    Forum Contributor
    Join Date
    12-17-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    137

    Re: count unique records in one column based on criteria in a different column

    Hi Davis,

    Is this logic will work for 40 Sheets. as per my below example. please Suggest and thanks for your help!

    For Example if I have two sheets, I should not manually enter Sheet 1 and Sheet 2 in the Code it is to be automated in the Code. Can you please help me on this.

    I need to Create Final sheet as in the Third Table.

    In Final Sheet I need to remove the duplicate and show in First Column and Number of FAIL in second Column and Number of PASS in Third Column.

    Please Note that the logic should work automatically even if the Client add a New sheet or delete the Existing Sheet. Please help me on this.

    Shee1

    Table Name Test Case Test Result
    ABC ABC_Test Case 1 PASS
    ABC ABC_Test Case 2 FAIL
    ABC ABC_Test Case 3 FAIL
    XYZ XYZ_Test Case 1 FAIL
    XYZ XYZ_Test Case 2 FAIL
    CDE CDE_Test Case 1 PASS
    CDE CDE_Test Case 2 PASS

    Sheet 2

    Table Name Test Case Test Result
    CCC CCC_Test Case 1 PASS
    CCC CCC_Test Case 2 FAIL
    DDD DDD_Test Case 1 FAIL
    DDD DDD_Test Case 2 PASS
    DDD DDD_Test Case 3 FAIL
    DDD DDD_Test Case 4 FAIL

    Final Sheet Should be created as below

    Table Name COUNT OF FAILS COUNT OF PASS
    ABC 2 1
    XYZ 2 0
    CDE 0 2
    CCC 1 1
    DDD 3 1

+ 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. [SOLVED] Count unique entries based off unique criteria in another column
    By hambly in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 06-11-2014, 03:33 PM
  2. Count unique occurrances based off criteria in a different column
    By Enovy in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-05-2013, 03:28 PM
  3. Count unique records in a column
    By bcn1988 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-20-2013, 11:51 AM
  4. [SOLVED] Count Unique Values in Column A that meet criteria in Column B
    By ashakespeare in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-04-2012, 07:33 PM
  5. Replies: 5
    Last Post: 09-18-2011, 10:44 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