+ Reply to Thread
Results 1 to 7 of 7

check value - merge and count

Hybrid View

Armitage2k check value - merge and count 06-18-2009, 02:00 PM
pike Re: check value - merge and... 06-18-2009, 04:46 PM
Armitage2k Re: check value - merge and... 06-19-2009, 11:35 AM
pike Re: check value - merge and... 06-21-2009, 05:56 AM
pike Re: check value - merge and... 06-21-2009, 08:48 AM
pike Re: check value - merge and... 06-21-2009, 04:09 PM
pike Re: check value - merge and... 06-21-2009, 06:17 PM
  1. #1
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Vietnam
    MS-Off Ver
    Excel 2010
    Posts
    382

    check value - merge and count

    Hello!

    I have following problem.
    I have a file with about 10,000 rows, each containing a column with a number, a date, text, text, number, number. that order, about 10,000 times.

    Now I have the great honor to check all these entries for duplicates (done), BUT, and this is where it gets tricky, some entries values are exactly the same.

    Example:

    A - B - C - D - E - F
    5 - 2009/01/01 - Bill Gates - Microsoft - 5 - 13
    5 - 2009/01/15 - Bill Gates - Microsoft - 6 - 17


    How do I manage to get Excel to count me that there are 2 entries, and then merge them together into one, but still showing me "2" in another colum?

    WANTED RESULT:
    A - B - C - D - E - F - H (!)
    10 - Date does not matter - Bill Gates - Microsoft - 11 - 30 - TOTAL 2 entries

    The date does not really matter and can actually be deleted. Anyway, I have been playing with CountIF but without success. any ideas?

    THANKS
    A2k
    Last edited by Armitage2k; 06-19-2009 at 11:36 AM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: check value - merge and count

    Hi Armitage 2K
    Have you tried a pivot table ?
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Vietnam
    MS-Off Ver
    Excel 2010
    Posts
    382

    Re: check value - merge and count

    ... damn it ^_^

    Actually I was looking for a more fancy method a la long complicated function or macro which makes this look like its incredible complicated, but that should work as well.

    cheers,
    A2k

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: check value - merge and count

    Something like
    Sub Complicate()
        Dim lRows As Long
         Application.ScreenUpdating = False
          With Sheet2.UsedRange
            lRows = .Rows.Count
            .Columns(4).Insert
             .Columns(4).FormulaR1C1 = _
            "= SUMPRODUCT(--(R2C[-2]:R" & lRows & "C[-2]=RC[-2])* --(R2C[-1]:R" & lRows & "C[-1]=RC[-1]))"
            .Columns(4).Value = .Columns(4).Value
            .Resize(, 4).AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=.Resize(, 4), CopyToRange:=Range("j1"), Unique:=True
            .Columns(4).Delete
        End With
         Application.ScreenUpdating = True
    End Sub
    Last edited by pike; 06-21-2009 at 05:58 AM. Reason: tags

  5. #5
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: check value - merge and count

    or even more so
    Sub complicate()
        Dim lRows As Long, a, iRows As Long, i As Long
         Application.ScreenUpdating = False
        a = Worksheets("Sheet2").Columns(1)
        Columns(1).Delete
          With Sheet2.UsedRange
            lRows = .Rows.Count
            .Columns(3).Insert
             .Columns(3).FormulaR1C1 = _
            "= SUMPRODUCT(--(R2C[-2]:R" & lRows & "C[-2]=RC[-2])* --(R2C[-1]:R" & lRows & "C[-1]=RC[-1]))"
            .Columns(3).Value = .Columns(3).Value
            .Resize(, 3).AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=.Resize(, 3), CopyToRange:=Range("N1"), Unique:=True
            .Columns(3).Delete
            End With
        Columns(1).Insert
        Columns(1) = a
       iRows = Cells(Rows.Count, 14).End(xlUp).Row
         For i = 1 To iRows
           Worksheets("Sheet2").Cells(i, 17).FormulaR1C1 = _
            "= SUMPRODUCT(--(R2C[-15]:R" & iRows & "C[-15]=RC[-15] )* --(R2C[-14]:R" & iRows & "C[-14]=RC[-14])*(R2C[-13]:R" & iRows & "C[-13]))"
             Worksheets("Sheet2").Cells(i, 18).FormulaR1C1 = _
            "= SUMPRODUCT(--(R2C[-16]:R" & iRows & "C[-16]=RC[-16])* --(R2C[-15]:R" & iRows & "C[-15]=RC[-15])*(R2C[-13]:R" & iRows & "C[-13]))"
        Worksheets("Sheet2").Cells(i, 8).FormulaR1C1 = _
            "=R" & i & "C[6]&"" - ""& R" & i & "C[7] &"" - ""&R" & i & "C[9]& "" - "" &R" & i & "C[10] & "" - "" &R" & i & "C[8]&  "" Total Entries"""
        Next
            Columns(17).Value = Columns(17).Value
            Columns(18).Value = Columns(18).Value
            Columns(8).Value = Columns(8).Value
            Columns(14).Delete
            Columns(14).Delete
            Columns(14).Delete
            Columns(14).Delete
            Columns(14).Delete
            Range("H1").Clear
         Application.ScreenUpdating = True
    End Sub

  6. #6
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: check value - merge and count

    Ops..two of the sumproducts should have been sum in formula array

    Sub complicated()
        Dim lRows As Long, a, iRows As Long, i As Long
         Application.ScreenUpdating = False
        a = Worksheets("Sheet1").Columns(1)
        Columns(1).Delete
          With Sheet2.UsedRange
            lRows = .Rows.Count
            .Columns(3).Insert
             .Columns(3).FormulaR1C1 = _
            "= SUMPRODUCT(--(R2C[-2]:R" & lRows & "C[-2]=RC[-2])* --(R2C[-1]:R" & lRows & "C[-1]=RC[-1]))"
            .Columns(3).Value = .Columns(3).Value
            .Resize(, 3).AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=.Resize(, 3), CopyToRange:=Range("N1"), Unique:=True
            .Columns(3).Delete
           .Columns(1).Insert
        .Columns(0) = a
       iRows = Cells(Rows.Count, 14).End(xlUp).Row
         For i = 1 To iRows
          .Cells(i, 16).FormulaArray = _
            "= SUM(--(R2C[-15]:R" & lRows & "C[-15]=RC[-3] )*(R2C[-14]:R" & lRows & "C[-14]=RC[-2])*(R2C[-13]:R" & lRows & "C[-13]))"
             .Cells(i, 17).FormulaArray = _
            "= SUM((R2C[-16]:R" & lRows & "C[-16]=RC[-4])* (R2C[-15]:R" & lRows & "C[-15]=RC[-3])*(R2C[-13]:R" & lRows & "C[-13]))"
        .Cells(i, 8).FormulaR1C1 = _
            "=R" & i & "C[5]&"" - ""& R" & i & "C[6] &"" - ""&R" & i & "C[8]& "" - "" &R" & i & "C[9] & "" - "" &R" & i & "C[7]&  "" Total Entries"""
        Next
          End With
             Columns(9).Value = Columns(9).Value
           Columns(17).Value = Columns(17).Value
           Columns(18).Value = Columns(18).Value
           For x = 1 To 5
            Columns(14).Delete
           Next x
            Range("I1").Delete
         Application.ScreenUpdating = True
    End Sub
    you'll need to change the sheet number/name to your value

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: check value - merge and count

    even confused myself
    use
    Sub very_complicated()
    Dim lRows As Long, iRows As Long, i As Long, x As Long
       Application.ScreenUpdating = False
        With Sheet1.UsedRange
            lRows = .Rows.Count
            .Columns(5).Insert
            .Columns(5).FormulaR1C1 = _
            "= SUMPRODUCT(--(R2C[-2]:R" & lRows & "C[-2]=RC[-2])* --(R2C[-1]:R" & lRows & "C[-1]=RC[-1]))"
            .Columns(5).Value = .Columns(5).Value
            .Range("C1:E" & lRows).AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=.Range("C1:E1"), CopyToRange:=Range("N1"), Unique:=True
            .Columns(5).Delete
            iRows = Cells(Rows.Count, 14).End(xlUp).Row
            For i = 1 To iRows
                .Cells(i, 16).FormulaArray = _
                "= SUM(--(R2C[-13]:R" & lRows & "C[-13]=RC[-3] )*(R2C[-12]:R" & lRows & "C[-12]=RC[-2])*(R2C[-11]:R" & lRows & "C[-11]))"
                .Cells(i, 17).FormulaArray = _
                "= SUM((R2C[-14]:R" & lRows & "C[-14]=RC[-4])* (R2C[-13]:R" & lRows & "C[-13]=RC[-3])*(R2C[-11]:R" & lRows & "C[-11]))"
                .Cells(i, 12).FormulaArray = _
                "= SUM((R2C[-9]:R" & lRows & "C[-9]=RC[1])* (R2C[-8]:R" & lRows & "C[-8]=RC[2])*(R2C[-11]:R" & lRows & "C[-11]))"
                .Cells(i, 8).FormulaR1C1 = _
                "=R" & i & "C[4]&"" - ""&R" & i & "C[5]&"" - ""& R" & i & "C[6] &"" - ""&R" & i & "C[8]& "" - "" &R" & i & "C[9] & "" - "" &R" & i & "C[7]&  "" Total Entries"""
            Next
        End With
        Columns(8).Value = Columns(8).Value
        For x = 1 To 6
            Columns(12).Delete
        Next x
        Range("H1").Value = "List"
        Application.ScreenUpdating = True
    end sub
    Last edited by pike; 06-21-2009 at 07:44 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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