Have a look at Filtered Selection Sets. I have a couple of functions that I use below. CreateEmptySSet as the name suggests returns an empty selection set and is used by CreateSSet. CreateSSet expects a True or False value to be passed as to whether the user should select objects & accepts a Parrameter Array of filter values. UseFiteredSSet is an example of how to use it in your project.
-------------------------------------------------------
Option Explicit
Public Sub UseFilteredSSet()
Dim objSSet As AcadSelectionSet
Dim objLine As AcadLine
Dim objBlockRef As AcadBlockReference
Set objSSet = CreateSSet(False, 8, lname, 0, "LINE")
For Each objLine In objSSet
Next objLine
objSSet.Delete
Set objSSet = CreateSSet(False, 8, lname, 0, "INSERT", 2, "ELB_90")
For Each objBlockRef In objSSet
Next objBlockRef
objSSet.Delete
End Sub
Public Function CreateSSet(blnUserSelect As Boolean, ParamArray varFilter() As Variant) As AcadSelectionSet
Dim intCount As Integer
Dim intFtype() As Integer
Dim varFdata() As Variant
Dim intIndex As Integer
Set CreateSSet = CreateEmptySSet
If UBound(varFilter) = -1 Then
If blnUserSelect = True Then
CreateSSet.SelectOnScreen
Else
CreateSSet.Select acSelectionSetAll
End If
Else
intIndex = ((UBound(varFilter) + 1) / 2) - 1
ReDim intFtype(intIndex)
ReDim varFdata(intIndex)
intIndex = 0
For intCount = 0 To UBound(varFilter) Step 2
intFtype(intIndex) = CInt(varFilter(intCount))
varFdata(intIndex) = varFilter(intCount + 1)
intIndex = intIndex + 1
Next intCount
If blnUserSelect = True Then
CreateSSet.SelectOnScreen intFtype, varFdata
Else
CreateSSet.Select acSelectionSetAll, , , intFtype, varFdata
End If
End If
End Function
Public Function CreateEmptySSet() As AcadSelectionSet
Dim blnExists As Boolean
Dim intCount As Integer
Dim strName As String
Dim objSSet As AcadSelectionSet
blnExists = True
intCount = 0
Do Until blnExists = False
blnExists = False
intCount = intCount + 1
strName = "SSET" & intCount
For Each objSSet In ThisDrawing.SelectionSets
If UCase(objSSet.Name) = strName Then blnExists = True
Next objSSet
Loop
Set CreateEmptySSet = ThisDrawing.SelectionSets.Add(strName)
End Function
-------------------------------------------------------
Regards - Nathan