Counting Multiple Items in Excel Based on Specific Criteria

China☆狼群 提交于 2019-12-08 07:23:06

问题


I looked through other questions and couldn't find what I needed.

Best if I explain as followed:

I have a spreadsheet that has three columns in it:

Product Name Vendor

Some vendors have the same product.

I need to count how many Product Names are identical by vendor.

All help is most appreciated.

Thank you,

user1114330


回答1:


Paste this formula in Cell C1

 =SUMPRODUCT(($A$1:$A$10=A1)*($B$1:$B$10=B1))

SNAPSHOT

However if you still want VBA, see this

Option Explicit

Sub Sample()
    Dim ws As Worksheet
    Dim lrow As Long

    Set ws = Sheets("Sheet1")

    With ws
        lrow = .Range("A" & .Rows.Count).End(xlUp).Row
        .Range("C1:C" & lrow).Formula = "=SUMPRODUCT(($A$1:$A$" & lrow & _
                                        "=A1)*($B$1:$B$" & lrow & "=B1))"
    End With
End Sub


来源:https://stackoverflow.com/questions/11066870/counting-multiple-items-in-excel-based-on-specific-criteria

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!