Objects are set but are always Nothing

Viewed 31

I wrote this procedure. But for some reason cc and ccc are always Nothing... Why?

Public Sub UpdateCurrentProcessIndexes(ByVal sh As Worksheet)
      
    Application.ScreenUpdating = False
    
        Dim d As New Scripting.Dictionary
        Dim c As Range
        Dim cc As Range
        Dim ccc As Range
        Dim i As Variant
        
        
        Set cc = Sheet20.ListObjects("Table_ProcessIndexes_All").ListColumns( _
        "Process Indexes all").DataBodyRange.Cells
        
        Set ccc = Sheet20.ListObjects("Table_ProcessIndexes_Selection").ListColumns( _
        "Process Indexes Selection").DataBodyRange
        
        '''' Iterate over all the cells in the source table and add unique cell values
        '''' to the dictionary. But only if their name also contains current sheet name.
        For Each c In cc
            If Not d.Exists(c.Text) And InStr(c.Text, sh.Name) Then
                Call d.Add(key:=c.Text, Item:=1)
            End If
        Next c
        
        '''' Empty the target table.
        If Not ccc Is Nothing Then
            ccc.Delete
        End If
        
        '''' Copy all the dictionary items to the target table.
        For Each i In d.Keys
                ccc.Cells(i, 0).Value = i.Text
        Next i    
    
    Application.ScreenUpdating = True

End Sub
0 Answers
Related