+ Reply to Thread
Results 1 to 3 of 3

Automatically add multiple original field entries total (that has multiple entries)

Hybrid View

  1. #1
    Registered User
    Join Date
    09-18-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Automatically add multiple original field entries total (that has multiple entries)

    Hi All,

    What I have is a spreadsheet of cities (there are multiple cities that are the same) - and they have a # of receives column too. What I want is to be able to add up all the cities #of receives that are the same City. for instance Dehli has over 50 lines of # of receives and instead of manually scrolling down and adding each cell together with a formula, I thought there would be an easier way to do this;

    SPreadsheet attached.

    Thanks for all your help!
    Attached Files Attached Files

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

    Re: Automatically add multiple original field entries total (that has multiple entries)

    Results added to column d

    Option Explicit
    Sub abc()
     Const shName As String = "sheet1" '<-- Change for you needs
     Dim aArr, i As Long
     
     With Sheets(shName)
        aArr = .Range("a1").CurrentRegion.Value
     End With
     
     With CreateObject("scripting.dictionary")
        .comparemode = 1
        For i = 1 To UBound(aArr, 1)
            If Not .exists(aArr(i, 1)) Then
                .Item(aArr(i, 1)) = aArr(i, 3)
            Else
                .Item(aArr(i, 1)) = .Item(aArr(i, 1)) + aArr(i, 3)
            End If
        Next
        For i = 2 To UBound(aArr, 1)
            Sheets(shName).Cells(i, "d") = .Item(aArr(i, 1))
        Next
     End With
    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.

  3. #3
    Registered User
    Join Date
    09-18-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Automatically add multiple original field entries total (that has multiple entries)

    Thank you kindly !

+ 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