+ Reply to Thread
Results 1 to 6 of 6

Summarize and sort VBA code based on deduplication greater than a certain condition

  1. #1
    Registered User
    Join Date
    08-31-2020
    Location
    Japan
    MS-Off Ver
    2016
    Posts
    94

    Summarize and sort VBA code based on deduplication greater than a certain condition

    De-duplication of the company in column A. Summarize the detailed data with an amount >= 500 and output the list sorting VBA
    Column D is de-duplicated, and the sum of the duplicates in column E must be greater than or equal to 500.

    Any help is greatly appreciated
    Attached Files Attached Files
    Last edited by Sakurayuki; 03-09-2022 at 08:23 AM.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Try this !


    According to your attachment a Windows only VBA demonstration for starters :

    PHP Code: 
    Sub Demo1()
        
    Dim VR&
            
    = [A1].CurrentRegion.Value2
                
    [D2].CurrentRegion.Offset(1).Clear
        With CreateObject
    ("Scripting.Dictionary")
                For 
    2 To UBound(V):  .Item(V(R1)) = .Item(V(R1)) + V(R2):  Next
            
    For Each V In .Keys
                
    If .Item(V) < 500 Then .Remove V
            Next
            
    If .Count Then
                
    [D3:E3].Resize(.Count).Value2 Application.Transpose(Array(.Keys, .Items))
                [
    D3:E3].Resize(.Count).Sort [D2], 1Header:=2
               
    .RemoveAll
            End 
    If
        
    End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 03-08-2022 at 10:24 AM.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Summarize and sort VBA code based on deduplication greater than a certain condition

    Please clarify.

    Do you mean the individual values in column B must be >500 to be included in the sum, or that the sum of all the individual for a company must be >500

    If the former then maybe =SUMIFS($B$2:$B$27,$A$2:$A$27,D3,$B$2:$B$27,">=500")

    But please clarify. Why in any case do you need VBA?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Lightbulb Or this …


    According to the attachment the classic Excel basics VBA demonstration :

    PHP Code: 
    Sub Demo2()
         
    Dim A$, B$, VWR&
             [
    D2].CurrentRegion.Offset(1).Clear
        With 
    [A1].CurrentRegion.Columns
             A 
    = .Item(1).Address
             B 
    = .Item(2).Address
            
    .Item(1).AdvancedFilter 2, , [D2], True
        End With
        With 
    [D2].CurrentRegion
            V 
    = .Value2
            W 
    Evaluate("IF({1},SUMIF(" "," & .Columns(1).Address "," "))")
        For 
    2 To UBound(V)
            If 
    W(R1) < 500 Then V(R1) = Empty Else V(R2) = W(R1)
        
    Next
           
    .Value2 V
           
    .Sort .Cells(1), 1Header:=1
        End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  5. #5
    Registered User
    Join Date
    08-31-2020
    Location
    Japan
    MS-Off Ver
    2016
    Posts
    94

    Re: Summarize and sort VBA code based on deduplication greater than a certain condition

    @Marc L You are so good, Thank you for the perfect solution

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Summarize and sort VBA code based on deduplication greater than a certain condition


    Thanks for the rep' !

    As a reminder Demo1 should crash with more than 65K ish rows …

+ 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. Dynamic sort based on a condition & its Ranking.
    By acsishere in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2017, 08:48 PM
  2. Dynamic sort based on a condition & its Ranking.
    By acsishere in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-11-2017, 03:08 PM
  3. Sort all names based on condition
    By xatomicx in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-17-2017, 01:44 AM
  4. Replies: 0
    Last Post: 04-28-2015, 03:56 PM
  5. use formular to caculate summarize with condition
    By thaimic in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-13-2013, 04:29 AM
  6. [SOLVED] Sort and Summarize by Zip Code
    By ExcelAteMyHomework in forum Excel General
    Replies: 2
    Last Post: 06-01-2012, 12:10 PM
  7. How to summarize the first 4 numbers greater than 0 from a list.
    By Antonio in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-24-2005, 07:35 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