شكرا لكم.
تنقيح أخير للكود:
Option Explicit
Function CountPeople(ByVal ID As String) As Integer
Dim People() As String, Item As String
Dim Items As Integer, Pos As Integer
Dim i As Integer, Count As Integer
ID = Replace(ID, " ", "", 1, -1)
If ID = "" Then Exit Function
People = Split(ID & "+", "+")
Items = UBound(People()) - 1
For i = 0 To Items
Item = People(i)
Select Case Item
Case "INF": 'Count = Count + 0
Case "SGL": Count = Count + 1
Case "DBL": Count = Count + 2
Case "TRP": Count = Count + 3
Case Else
Pos = InStr(1, Item, "CH(")
If Pos > 0 Then
If Pos = 1 Then
Count = Count + 1
Else
Count = Count + Val(Left(Item, Pos - 1))
End If
End If
End Select
Next i
CountPeople = Count
End Function