Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8019325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:21:26+00:00 2026-06-04T21:21:26+00:00

I have to do sumif multiple time to get this problem solved. Problem: I

  • 0

I have to do sumif multiple time to get this problem solved.

Problem:
I have a table with Part Number as the first column and it is always the same for unique part. However, the description 1 and description 2 are not perfect, even for the same part number (due to the typo, etc). I need to combine the Quantity at different inventories: QTY AT V1, V2, and V3

enter image description here

The result if I use multiple sumif and choose the the description appears first. Of course, there are like 50k of rows with many different PN#. Error often occurs if using sumif due to human error.

I would like to ask for help on this one.
Compare the PN# if they are the same sum the quantity at different inventory locations, the description 1 and 2 just pick up whatever appear first (like CAR – BLACK and 4 WHEELS).

There are some similar questions and answers to this. However, they do not work well.
Merge Cells

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:21:27+00:00Added an answer on June 4, 2026 at 9:21 pm

    This should solve your problem. I set up a workbook with 2 tabs: RawData and PNTotals. I created data that resembles the two rows in your example. I have 26 rows with 3 different PN#s: Honda, Toyota, and Kia. The code works regardless of how many rows and PN#s you have.

    After running the code below, I end up with totals by PN on the PNTotals tab that look like this:

    HONDA   CAR - BLACK   4 WHEELS        936   516 2214
    TOYOTA  CAR                           864   414 2079
    KIA     CAR - RED     SPORT PACKAGE   504   204 1234
    

    To get this to work, add the following code to a module and run the sub DispatchTotalsByPNNumber().

    Option Explicit
    
    Sub DispatchTotalsByPNNumber()
        Dim LastPN As Long
    
        LastPN = Sheets("RawData").Range("A1").End(xlDown).Row
    
        GetDistinctListOfPNNumbers (LastPN)
        GetQuantityTotalsForEachPNNumber (LastPN)
    
    End Sub
    Sub GetDistinctListOfPNNumbers(ByVal LastPN As Long)
    
        Sheets("PNTotals").Cells.Clear
        Sheets("RawData").Range("A2:A" & LastPN).Copy Sheets("PNTotals").Range("A1")
        Sheets("PNTotals").Range("a:a").RemoveDuplicates Columns:=1, Header:=xlNo
    End Sub
    Function DescCols(ByVal LastPN As Long) As Integer
        Dim i As Integer
    
        For i = 2 To 10 ' If you ever have more than 9 description columns, increase range here
             If Not IsNumeric(Cells(Cells(LastPN + 1, i).End(xlUp).Row, i)) Then
                DescCols = DescCols + 1
            Else
                Exit Function
            End If
        Next i
    End Function
    
    Sub GetQuantityTotalsForEachPNNumber(ByVal LastPN As Long)
        Dim i As Long
        Dim x As Integer
        Dim TotCols As Integer
        Dim PNN As String
        Dim ThisColumn As String
        Dim PNCount As Integer
    
        TotCols = Sheets("RawData").Range("A1").End(xlToRight).Column
        PNCount = 1
        ' get count of PN#s if there are more than 1
        If Sheets("PNTotals").Range("A2").Value <> "" Then
            PNCount = Sheets("PNTotals").Range("a1").End(xlDown).Row
        End If
    
        For i = 1 To PNCount
            PNN = Sheets("PNTotals").Range("A" & i).Value
            Sheets("RawData").Select
            Sheets("RawData").Range("A1").Select
            Sheets("RawData").Cells.Find(What:=PNN, after:=ActiveCell, searchorder:=xlByRows).Activate
    
            ' Copy description text from first instance of pn to total sheet for all description columns
            For x = 1 To DescCols(LastPN)
                Sheets("PNTotals").Cells(i, x + 1).Value = ActiveCell.Offset(, x).Value
            Next
            For x = x + 1 To TotCols
                ThisColumn = GetColumnLetter(x)
            ' set sumif formulas for however many quantity columns we have
            Sheets("PNTotals").Range(ThisColumn & i).Formula = "=SUMIF(RawData!A2:" & ThisColumn & LastPN & ",PNTotals!A" & i & ",RawData!" & ThisColumn & "2:" & ThisColumn & LastPN & ")"
    
            Next
        Next
    End Sub
    
    Function GetColumnLetter(ByVal ColNum As Integer) As String
    
        GetColumnLetter = Left(ActiveSheet.Cells(1, ColNum).Address(False, False), (ColNum <= 26) + 2)
    
    End Function
    

    NOTES: Assumes raw data starts in cell A1 of the RawData sheet and that there aren’t any blank PN#s. If there are blanks, you’ll need to determine the last PN row differently.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table of user-generated content that includes an ENUM format column for
I have this table select * from points +---------+------+------+ | NAME | Type |
I am working on this problem where I have couple of machines on network.
So I have a mysql table which has a id column (sid) that can
have a php code like this,going to convert it in to C#. function isValid($n){
Have data that has this kind of structure. Will be in ascending order by
Have data that has this kind of structure: $input = [ { animal: 'cat',
I have a MySQL UPDATE query which takes a long time to complete. Am
I have this tail recursive function here: def recursive_function(n, sum): if n < 1:
I really need a calculated column on a table with simple sum. Please see

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.