個別地分類されたフィーチャの数をカウント

'個別地分類されたフィーチャの数をカウント(この方法は遅い)
Public Sub Test()
    '現在のドキュメントを取得
    Dim pMxDocument As IMxDocument
    Set pMxDocument = ThisDocument
    
    'アクティブなデータフレームの取得
    Dim pMap As IMap
    Set pMap = pMxDocument.FocusMap
    
    'レイヤを取得
    Dim pLayer As ILayer
    Set pLayer = pMap.Layer(0)
'    Set pLayer = pMap.Layer(InputBox("Layer Index ?"))
    
    'フィーチャレイヤを取得
    Dim pGeoFeatureLayer As IGeoFeatureLayer
    Set pGeoFeatureLayer = pLayer
    
    Dim pFeatureClass As IFeatureClass
    Set pFeatureClass = pGeoFeatureLayer.FeatureClass
    
    Dim pUniqueValueRenderer As IUniqueValueRenderer
    Set pUniqueValueRenderer = pGeoFeatureLayer.Renderer
    
    Dim pQueryFilter As IQueryFilter
    Set pQueryFilter = New QueryFilter
    
    Dim pFeatureCursor As IFeatureCursor
    Dim pFeature As IFeature
    
    Dim counter As Long
    
    Dim i As Long
    For i = 0 To pUniqueValueRenderer.ValueCount - 1
        counter = 0
        pQueryFilter.WhereClause = pUniqueValueRenderer.Field(0) & " = """ & pUniqueValueRenderer.Value(i) & """"   '属性が文字の場合
        pQueryFilter.WhereClause = pUniqueValueRenderer.Field(0) & " = " & pUniqueValueRenderer.Value(i) & ""   '属性が数値の場合
        
        Set pFeatureCursor = pFeatureClass.Search(pQueryFilter, True)
        Set pFeature = pFeatureCursor.NextFeature
        Do Until pFeature Is Nothing
            counter = counter + 1
            Set pFeature = pFeatureCursor.NextFeature
        Loop
        
        pUniqueValueRenderer.Label(pUniqueValueRenderer.Value(i)) = pUniqueValueRenderer.Value(i) & " " & counter
        
    Next i
    
    pMxDocument.UpdateContents

End Sub