'Error in my VBA Selection.SpecialCells(xlCellTypeConstants, 1) cell.Value = cell.Text

Hello I have an excel program that filters my table when I copy/paste my references in column J. However depending on where I copied the references it doesn't work.

VBA tells me this : Selection.SpecialCells(xlCellTypeConstants, 2)

I do not understand why.

Here is my program:

Sub DoMyFilter()

    Columns("A:J").Select
    Selection.NumberFormat = "@"

        Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    Dim cell As Range
    For Each cell In _
           Selection.SpecialCells(xlCellTypeConstants, 1)
       cell.Value = cell.Text
    Next cell
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    
    Dim vCrit As Variant
    Dim aCrit As Variant
    
    vCrit = Range("J2:J100000").Value
    aCrit = Application.Transpose(vCrit)
    
    ActiveSheet.Range("$A$1:$H$7634").AutoFilter Field:=1, Criteria1:=aCrit, Operator:=xlFilterValues
    
    Range("J:J").ClearContents
    
End Sub

Can anyone help me ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source