答案1
以下是列表:
Public Function WhatsInThere(rng As Range) As String
Dim r As Range, v As String, c As Collection, ary, a
Set c = New Collection
WhatsInThere = ""
On Error Resume Next
For Each r In rng
v = r.Text
If v <> "" Then
If InStr(1, v, ",") = 0 Then
c.Add v, CStr(v)
If Err.Number = 0 Then WhatsInThere = WhatsInThere & "," & v
Err.Number = 0
Else
ary = Split(v, ",")
For Each a In ary
c.Add a, CStr(a)
If Err.Number = 0 Then WhatsInThere = WhatsInThere & "," & a
Err.Number = 0
Next a
End If
End If
Next r
On Error GoTo 0
WhatsInThere = Mid(WhatsInThere, 2)
End Function
要计算项目数,只需数出逗号并加一。