我想要实现的是返回列中唯一值(字符串)的列表。将该列表放入一个数组中,然后将值列表粘贴到一个新工作表中,例如列 A。然后对于每个数组元素计算它在原始列表中出现的次数,并返回其在新工作表中 B 列中的频率计数其唯一的字符串。
到目前为止,这是我的代码。
Sub UniqueList()
Dim rListPaste As Range
Dim causeList As Range
Dim iReply As Integer
Dim element As Variant
On Error Resume Next
Set rListPaste = Application.InputBox _
(Prompt:="Please select the destination cell", Type:=8)
If rListPaste Is Nothing Then
iReply = MsgBox("No range nominated," _
& " terminate", vbYesNo + vbQuestion)
If iReply = vbYes Then Exit Sub
End If
causeList = Range("E1", Range("E65536").End(xlUp))
Range("causeList").AdvancedFilter Action:=xlFilterCopy, Unique:=True
Range("causeList").AdvancedFilter CopyToRange:=causeList.Cells(1, 1)
element = 0
For Each element In causeList
element = element + 1
Next element
End
End Sub