excel autofilter where criteria is the cell value must not contain a letter or a number

Advertisements

i have a range A to N, initially i filter it by H(field 8) then I want to filter it again by column N(field 14) with the criteria that the rows in column N must not contain a letter or a number, how would be the way to do that?

rng.AutoFilter Field:=8, Criteria1:="Value" 'Filter by Column H
rng.AutoFilter Field:=14, Criteria1:=       'Filter by Column N

>Solution :

Have to create another column with this formula and filter this column:

Function hasDigitsOrNumbers(s As String) As String
    Dim ch As String, ln As Long
    Dim i As Long
    
    ln = Len(s)

    For i = 1 To ln
        ch = Mid(s, i, 1)
        If (ch >= "0" And ch <= "9") Or (ch >= "a" And ch <= "z") Or (ch >= "A" And ch <= "Z") Then
            hasDigitsOrNumbers = True
            Exit Function
        End If
    Next
    hasDigitsOrNumbers = False
End Function

=hasDigitsOrNumbers(N1) and returns true if the N1 has digits or letters, otherwise returns FALSE.

Leave a Reply Cancel reply