+ Reply to Thread
Results 1 to 4 of 4

Thread: advanced SUMIF problems

  1. #1
    Registered User
    Join Date
    12-15-2010
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    1

    advanced SUMIF problems

    Hi
    I am working on a tool that sumerizes weights of product packages. The material level formulas and calculation of weights are all done, but I need help with a formula that sumerizes these weights on product package level only.

    Exampel
    Large amount of data will be insterted into column A and weights will be automatically calculated in column B. Column C should then sumerize these weights based on if column A starts with letter or a dot. When underlying material exist it should sumerize this all the way down to next product package which always begins with letter and not a dot. Sometimes a product package have underlying material sometimes it does not. i.e the rows in green is where I would like to have these sumerizes.

    The formula will be draged down maybe thousand rows so it cannot involve any manual editing. Does anyone have an idea how to help me with this?

    Example can be seen in attached.

    Thanks in advance for all your help!
    BR Marcus
    Attached Files Attached Files

  2. #2
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,220

    Re: advanced SUMIF problems

    With a helper column, maybe?

    See the attached updated example.

    Regards
    Attached Files Attached Files

  3. #3
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: advanced SUMIF problems

    The below is far from ideal given it goes against "best practice" re: design of calcs (looking down rather than up)

    D2:
    =IF(OR(LEFT($B2)=".";$B2="");"";SUM($C2:$C$15)-SUM($E3:$E$16))
    copied down to D15

  4. #4
    Registered User
    Join Date
    05-25-2010
    Location
    Trinidad
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: advanced SUMIF problems

    Spent some time on this one as the counters were throwing me off..

    Anyways see below and let me know if you need any modifications. this places the summary in column D and at the start of the new cell with a letter...

    Option Explicit
    Public Sub SumValues()
    Dim sumField As Double, cellValue As String, counter As Long, totalRows As Long, cellCount As Long
    
    counter = ActiveSheet.UsedRange.Rows.Count
    cellValue = Left(Cells(counter, 2), 1)
    sumField = Cells(counter, 3)
    
    While (counter >= 2)
    
    cellValue = Left(Cells(counter, 2), 1)
    If (cellValue = ".") Then
    cellCount = cellCount + 1
        If (cellCount = 1) Then
        sumField = 0
        sumField = sumField + Cells(counter, 3)
        Else
        sumField = sumField + Cells(counter, 3)
     
    End If
    Else
        If (cellCount >= 1) Then
        sumField = sumField + Cells(counter, 3)
        Cells(counter, 4) = sumField
    sumField = 0
        Else
        sumField = Cells(counter, 3)
        Cells(counter, 4) = sumField
        sumField = 0
        cellCount = 0
        End If
    End If
    
    counter = counter - 1
    Wend
    End Sub

+ 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.2.0