Here is the corrected code
Option Explicit
Dim blockZ As AcadBlock 'ThisDrawing.Blocks..
Dim getBlock As AcadEntity 'Select a block to count..
Dim no_of_blocksX As Integer 'Number of blocks (selected)..
Dim allBlocks As Integer 'Number of block (in entire drawing)..
Dim basex As Variant 'Pick point for block selection..
Dim Lblockname As String, Lblockname2 As String 'Left character in the blockname (to filter out unwanted blocks from the list)..
Dim checkname As Integer 'Compares actual block names with combobox block names..
Dim SSet As AcadSelectionSet 'Selection set for blocks..
Dim blockname As String 'Name of block picked..
Dim response As Integer 'Yes / No..
' Update the block count each time the combobox text is changed..
Private Sub BlockNameCMBO_Change()
For Each SSet In ThisDrawing.SelectionSets
If SSet.Name = "GetBlocks" Then
SSet.Delete
End If
Next SSet
blockname = BlockNameCMBO.Text
Dim FilterType(0 To 1) As Integer 'Selection Set - Filter type..
Dim FilterData(0 To 1) As Variant 'Selection Set - Filter data..
' Create a selection set..
Set SSet = ThisDrawing.SelectionSets.Add("GetBlocks")
FilterType(0) = 0: FilterData(0) = "INSERT"
FilterType(1) = 2: FilterData(1) = blockname
SSet.Select acSelectionSetAll, , , FilterType, FilterData
no_of_blocksX = SSet.Count
lblTotal.Caption = no_of_blocksX
End Sub
' Select a block..
Private Sub PickBlockBTN_Click()
blockcountform.Hide
On Error Resume Next
TryAgain:
ThisDrawing.Utility.GetEntity getBlock, basex, vbCr & "Select a block to count.. "
ErrHndlr:
If Err.Number <> 0 Then
Err.Clear
GoTo TryAgain
End If
On Error GoTo ErrHndlr
BlockNameCMBO.Text = getBlock.Name 'Show the selected block name in the combobox..
blockcountform.Show
End Sub
'********************************************
'*************** FORM LOAD ****************
'********************************************
Private Sub UserForm_Initialize()
For Each blockZ In ThisDrawing.Blocks
Lblockname = Left(blockZ.Name, 1): Lblockname2 = Left(blockZ.Name, 2)
If Lblockname <> "_" And Lblockname <> "*" And Lblockname2 <> "A$" Then
With BlockNameCMBO
.AddItem (blockZ.Name)
End With
End If
Next
End Sub
'********************************************
'*************** FORM LOAD ****************
'********************************************
'********************************************
'*************** FORM UNLOAD ****************
'********************************************
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
response = MsgBox("Are you sure you've finished with the 'Block Counter program?..", vbQuestion + vbYesNo, "End the Program..")
If response = vbNo Then
Cancel = 1
End If
If response = vbYes Then
Unload Me
End If
End Sub
'********************************************
'************* END FORM UNLOAD **************
'********************************************
Like Bryco said, your filter pairs were off a little, but I fixed it. I also changed the names of some of your vars because it was way too confusing using a var with a sset of the same name