I made a short script to update a table with values, that are counted in another workbook. Unfortunately I get a type mismatch error for the Countif function. I suspect, that I define the selected range wrong. Could someone tell me, what I'm missing here? Here is the code I wrote so far:

Sub DSupdate()
'On Error GoTo ErrHandler
Application.ScreenUpdating = False
        
Dim DStbl As ListObject
Dim hName As String
Dim srcApp As New Excel.Application
Dim srcWb As New Excel.Workbook
Dim srcSht As Worksheet
Dim srcTbl As ListObject
Dim DSsol As String
Dim DSname As String
Dim src_directory As String

For x = 2 To 10

y = 2

Set DStbl = ActiveSheet.ListObjects("DS")

hName = DStbl.HeaderRowRange(x).Value
    
        'define source file path

src_directory = "C:\Users\xxxxxx\Desktop\one.Directory_Instances_and_Ports.xlsx"
Set srcWb = srcApp.Workbooks.Open(src_directory)
DSsol = hName & "(DS)"
Set srcSht = srcWb.Worksheets(DSsol)
Set srcTbl = srcSht.ListObjects(1)

        'update cell values in table columns

For Each Cell In DStbl.ListColumns(x).DataBodyRange

DSname = DStbl.Range(y, 1).Value

With srcSht
    .Activate
    .Select

        'count DSentries based on selected sheet
 
ActiveCell.Value = Application.WorksheetFunction.CountIf(srcTbl.Range, DSname)
        
If ActiveCell.Value = 0 Then

MsgBox (DSname & Cell.Address)

Else

ActiveCell.Value = ActiveCell.Value
        
End If

End With

y= y + 1

Next

Next x

srcWb.Close False
Set srcWb = Nothing
        
'ErrHandler:
'Application.EnableEvents = True
'Application.ScreenUpdating = True

End Sub