+ Reply to Thread
Results 1 to 10 of 10

Return and non-duplicate SUMIF data

Hybrid View

  1. #1
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Return and non-duplicate SUMIF data

    How could I have seen VBA, the data in column "A" no duplicates in the column "E" and the sum of these criteria in column "F".

    See Attachment

    Thank's
    Attached Files Attached Files
    Last edited by marreco; 05-22-2012 at 07:57 AM.
    "No xadrez nem sempre a menor dist?ncia entre dois pontos ? uma linha reta" G. Kasparov.

    If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select b from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.

  2. #2
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Return and non-duplicate SUM data

    Hi use builtin function of excel in VAB
    Sub aa()
    [f2] = Application.WorksheetFunction.SumIf([a2:a26], [e2], [b2:b26])
    End Sub
    I think You can adjust it to your needs
    Last edited by tom1977; 05-22-2012 at 07:53 AM.
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  3. #3
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Return and non-duplicate SUM data

    Not so.

    the code needs to go céluas of the column a "A" and see how many I have different data.

    then he sends this reultado to column "E" is the code I have found that 3 data only ones he will return me the total of each column as one "F" under the column "E".

  4. #4
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Return and non-duplicate SUMIF data

    option
    Sub ertert()
    Dim x, y(), i&, j&, k&, n&, s$
    
    x = Range("A2:B" & Cells(Rows.Count, 1).End(xlUp).Row).Value
    ReDim y(1 To UBound(x), 1 To 2)
    
    On Error Resume Next
    With New Collection
        For i = 1 To UBound(x)
            s = Trim$(x(i, 1))
            If Len(s) Then
                If IsEmpty(.Item(s)) Then
                    k = k + 1: y(k, 1) = s: y(k, 2) = x(i, 2)
                    .Add k, s
                Else
                    n = .Item(s): y(n, 2) = y(n, 2) + x(i, 2)
                End If
            End If
        Next i
    End With
    
    If k > 1 Then [e2:f2].Resize(k).Value = y
    End Sub

  5. #5
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Return and non-duplicate SUMIF data

    It was great!

    But is giving the end of the column "E" value of 633.4

    in my case I do not have value.
    can eliminate this part?
    it can also comment on the code, I am grateful

  6. #6
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Return and non-duplicate SUMIF data

    try this
    Sub bb()
    Dim lasta, laste As Long
    Dim nam, nam1, c As Range
    lasta = Cells(Rows.Count, 1).End(xlUp).Row
    Set nam = Range("a1:a" & lasta)
    nam.Copy [e1]
    nam.Offset(0, 4).RemoveDuplicates Columns:=1, Header:=xlYes
      laste = Cells(Rows.Count, 5).End(xlUp).Row
      Set nam1 = Range("e2:e" & laste)
      For Each c In nam1
      c.Offset(, 1) = Application.WorksheetFunction.SumIf(nam, c, nam.Offset(0, 1))
      Next
      
    End Sub
    works only with ex>2007

  7. #7
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Return and non-duplicate SUMIF data

    Look into your file column A row 64

  8. #8
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Return and non-duplicate SUMIF data

    Thank you!!!

    thank you both!

    Thank you very much!

  9. #9
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Return and non-duplicate SUMIF data

    Why do you want VBa for this?
    In E2
    =LOOKUP(REPT("Z",255),CHOOSE({1;2},"",INDEX($A$2:$A$1000,MATCH(TRUE,INDEX(ISNA(MATCH($A$2:$A$1000,$E$1:$E1,0)),0),0))))
    In F2
    =IF(E2="","",SUMIF($A$2:$A$1000,E2,$B$2:$B$1000))
    Drag/Fill both Down
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  10. #10
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: Return and non-duplicate SUMIF data

    If anyone can comment codes be very grateful!

    nilem could you comment your code?

+ 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