Во-первых, "и нечего так орать" (с)
Во-вторых, справка разработчика из-под AutoCAD отлично все описывает.
В-третьих, есть [штатная] команда bcount. Идет вместе с Express Tools (правда, она не обрабатывает динамические блоки).
В-четвертых, код я бы писал на лиспе.
В-пятых, если сильно хочется VBA (также без дин.блоков):
Option Explicit
Option Base 0
Public Type typRes
sName As String
lRange As Long
End Type
Public Sub CountBlockWithNames()
Dim oSelSet As AcadSelectionSet, SelSetName As String
Dim fType(0) As Integer, fData(0) As Variant
Dim oAcadEnt As AcadEntity
Dim Result() As typRes, lCounter As Long, AddNew As Boolean
SelSetName = "bc"
For Each oSelSet In ThisDrawing.SelectionSets
If oSelSet.Name = SelSetName Then
oSelSet.Delete
Exit For
End If
Next oSelSet
Set oSelSet = ThisDrawing.SelectionSets.Add(SelSetName)
fType(0) = 0: fData(0) = "INSERT"
oSelSet.SelectOnScreen fType, fData
For Each oAcadEnt In oSelSet
On Error GoTo lErrorReDim
If UBound(Result) < 0 Then
ReDim Result(0)
'On Error GoTo 0
Result(0).sName = oAcadEnt.Name
Result(0).lRange = 1
Else
AddNew = True
For lCounter = 0 To UBound(Result)
If Result(lCounter).sName = oAcadEnt.Name Then
Result(lCounter).lRange = Result(lCounter).lRange + 1
AddNew = False
Exit For
End If
Next lCounter
If AddNew Then
ReDim Preserve Result(UBound(Result) + 1)
Result(UBound(Result)).sName = oAcadEnt.Name
Result(UBound(Result)).lRange = 1
End If
End If
Next oAcadEnt
oSelSet.Delete
' Сервисная часть - показать MsgBox
Dim MessageString As String
For lCounter = 0 To UBound(Result)
If MessageString = "" Then
MessageString = Result(lCounter).sName & " : " & CStr(Result(lCounter).lRange)
Else
MessageString = MessageString & vbCrLf & _
Result(lCounter).sName & " : " & CStr(Result(lCounter).lRange)
End If
Next lCounter
MsgBox MessageString
Exit Sub
lErrorReDim:
ReDim Result(0)
Err.Clear
Resume Next
End Sub