I am trying to loop through each cell in a column and count the number of cells having 'e' in their texts but keep getting "Application-defined or object-defined error" error message. Below is what I've got. Please help.
Dim REX As RegExp
Dim oMatch As Object
Dim count As Integer
Dim c As Range
Set REX = CreateObject("VBScript.RegExp")
.Global = True
.IgnoreCase = True
.Pattern = "*e"
count = 0
For Each c In Range("F2:F500").Cells
If REX.Test(c.Value) Then 'the error message is thrown here
Set oMatch = REX.Execute(c.Value)
If Not oMatch Is Nothing Then
count = count + 1
Set oMatch = Nothing
Please note that I have added 'Microsoft VBScript Regular Expressions 5.5' to References of the project.