我有一个由客户提交的记录列表,并且我的记录列表包含重复提交的内容。
我可以在宏中使用什么公式来计算基于每个客户的唯一记录列表?
查看我的示例数据
Record Name Submitted By Status
Lead-123 Peter H Rejected
Lead-495 Carlos Sinbad Rejected
Lead-496 Carlos Sinbad Approved
Lead-101 Timothy Johnson Approved
Lead-421 Timothy Johnson Approved
Lead-421 Timothy Johnson Approved
Lead-421 Timothy Johnson Approved
Lead-421 Timothy Johnson Rejected
Lead-393 Derik Fauster Recalled
Lead-393 Derik Fauster Approved
Lead-422 Derik Fauster Rejected
Lead-422 Derik Fauster Rejected
Lead-422 Derik Fauster Rejected
我想要的
# of Unique Records Submitted Submitted By
1 Peter H
2 Carlos Sinbad
2 Timothy Johnson
2 Derik Fauster
我已经尝试过了
Sub CountUniqueValues()
Dim LstRw As Long, Rng As Range, List As Object
LstRw = Cells(Rows.Count, "A").End(xlUp).Row
Set List = CreateObject("Scripting.Dictionary")
For Each Rng In Range("A2:A" & LstRw)
If Not List.Exists(Rng.Value) Then List.Add Rng.Value, Nothing
Next
MsgBox "There are " & List.Count & " unique values in column A from row 2 down."
End Sub
但是我只能获得“记录名称”的唯一记录,而不能将其与唯一的“提交人”联系起来。
答案 0 :(得分:0)
我已经回答了我自己的问题。我能够根据名称条件对唯一记录进行计数。
下面是我修改的代码,该代码捕获了我范围内的所有数据并相应地对记录进行计数。
d <- structure(list(class = c("foo", "bar", "baz", "baz", "bar", "foo",
"foo", "foo", "foo"), id = c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L,
3L)), row.names = c(NA, -9L), class = "data.frame")