• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Working with Operator like

salim hasan

Member
Hy every one
I have a column with same data like:
School1 ,Class1,School2 ,Class5,School20 ,Class8,School ,Class20,Class....
an I want to match all the cells that not ending by a numbers(Class,School) for
example
Also all the cells that ending by a numbers (School2 ,Class5,School20 ,Class8...)
what is the like Operator for this cases?
or the pattern (Regex)
 
Hello Salim
How are you doing?
Try this code using Like operator
Code:
Sub Test()
    Dim c As Range

    For Each c In Cells(1).CurrentRegion
        If c.Value Like "*#" Then
            Debug.Print "With Numbers : " & c.Value
        ElseIf c.Value Like "*[!#]" Then
            Debug.Print "Without Numbers : " & c.Value
        End If
    Next c
End Sub
 
Hello Salim
How are you doing?
Try this code using Like operator
Code:
Sub Test()
    Dim c As Range

    For Each c In Cells(1).CurrentRegion
        If c.Value Like "*#" Then
            Debug.Print "With Numbers : " & c.Value
        ElseIf c.Value Like "*[!#]" Then
            Debug.Print "Without Numbers : " & c.Value
        End If
    Next c
End Sub
Excellent!
TVM (Thank you Very much)
 
Last edited:
Back
Top