+ Reply to Thread
Results 1 to 5 of 5

Making one row of many

Hybrid View

  1. #1
    Registered User
    Join Date
    12-17-2012
    Location
    Hungary, budapest
    MS-Off Ver
    Excel 2007
    Posts
    13

    Making one row of many

    Hi Guys

    I'm looking for a way to make one row of many others, and summarize only the numbers they contain. My example is the following:

    Raw data:

    A1: Anything, B1: 2
    A2: Something, B2: 6
    A3: Something, B3: 1
    A4: Nothing, B4: 1

    The result I want:

    A1: Anything, B1: 2
    A2: Something, B2: 7
    A3: Nothing, B4: 1

  2. #2
    Forum Contributor
    Join Date
    08-23-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    163

    Re: Making one row of many

    Hi,

    If I am getting it correctly....you need the sum of values in colum B if condition matches.

    I think Sumif function will be helpful. Please check the attached s/s.
    Attached Files Attached Files

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Making one row of many

    or a pivot table

  4. #4
    Registered User
    Join Date
    12-17-2012
    Location
    Hungary, budapest
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Making one row of many

    Thank you Guys! But I was looking for a VBA solution. So I'm going to make a similar post and ask my question more correctly.

  5. #5
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Making one row of many

    This might work

    Sub abc()
     Dim a, i As Long
     
     a = Range("a1", Cells(Rows.Count, "a").End(xlUp).Offset(, 1))
     
     With CreateObject("scripting.dictionary")
        .comparemode = 1
        For i = 1 To UBound(a)
            If Not .exists(a(i, 1)) Then
                .Item(a(i, 1)) = Array(a(i, 1), a(i, 2))
            Else
                 a(i, 2) = .Item(a(i, 1))(1) + a(i, 2)
                .Item(a(i, 1)) = Array(a(i, 1), a(i, 2))
            End If
        Next
        a = .items
     End With
     
     Worksheets.Add
     For i = 0 To UBound(a)
        Cells(i + 1, "A") = a(i)(0)
        Cells(i + 1, "B") = a(i)(1)
     Next
    End Sub
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

+ 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