-2

计算其他 2 列满足特定条件的列的唯一值。假设 A 列是重复的索赔编号列表,因为每个索赔在多个月中有多个账单(月份是 B 列,位置是 C 列),每一行代表一个账单。我需要能够使用 month=3 和 location="Chicago" 的标准来计算唯一的索赔编号

-Claim #   Month   Location
-1234      3       Chicago
-1234      3       Chicago
-1234      3       Chicago
-1234      3       Chicago
-3215      3       Chicago
-3215      3       Chicago
-3215      3       Chicago
-1334      4       Chicago
-1334      5       Chicago
-1235      3       Philadelphia

这里的答案应该是2

4

1 回答 1

0

试试这个小宏:

Sub dural()
    Dim c As Collection
    Set c = New Collection
    Dim N As Long, i As Long
    N = Cells(Rows.Count, "A").End(xlUp).Row
    For i = 1 To N
        If Cells(i, 2).Value = 3 And Cells(i, 3).Value = "Chicago" Then
            On Error Resume Next
            c.Add Cells(i, 1), CStr(Cells(i, 1))
        End If
    Next
    MsgBox c.Count
End Sub
于 2013-10-21T19:48:27.407 回答