Consulting

Results 1 to 6 of 6

Thread: Looking to condense data with quantity totals

  1. #1

    Looking to condense data with quantity totals

    Trying to condense like data with quantities and total them. So far I've been able to sort their like data but not able to condense and sum their totals. This is the actual data the sorts it, this works great but does not condense the data. "M" column is the width, "N" column is the by symbol (x), "O" column is the length, and "P" column is the quantity. What I'm looking to do is, if matching data in (M) and (O) combine them and sum their quantities into one total.

    'This code will sort the data first by "width" then by "length"
    Private Sub SortData_Click()
    
    
    Sheets("Order200").Range("M3:P" & Sheets("Order200").Range("M3").End(xlDown).row).Sort _
    key1:=Sheets("Order200").Range("M:M"), order1:=xlAscending, _
    key2:=Sheets("Order200").Range("O:O"), order2:=xlAscending, _
    Header:=xlNo
    
    
    End Sub

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    I'd use a pivot table
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    Quote Originally Posted by Paul_Hossler View Post
    I'd use a pivot table

  4. #4
    Thank You, I'll have to look into using a pivot table.

  5. #5
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    Quote Originally Posted by CellarDude View Post
    Thank You, I'll have to look into using a pivot table.

    If you attach a small representative sample workbook, I'm sure you'll be able to get lots of suggestions
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  6. #6
    VBAX Expert
    Joined
    Sep 2016
    Posts
    788
    Location
    Sub test()
        Dim r As Range
        
        Set r = Worksheets.Add.Cells(1)
        Sheets("Order200").Columns("M:P").Copy r
        Set r = r.CurrentRegion
        Set r = Intersect(r, r.Offset(2)).Resize(, 5)
        
        r.Columns(5).FormulaR1C1 = "=sumifs(c4:c4,c1:c1,rc1,c3:c3,rc3)"
        r.Value = r.Value
        r.RemoveDuplicates Array(1, 2, 3)
        r.Columns(4).Delete xlToLeft
    
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •