Hi Team,
I am converting working code into function. and calling from module.
Getting error argument not Optional. can you suggest whats wrong here. thanks.
Error line ------> If CheckMonth(str) = True Then
Thanks
mg
I am converting working code into function. and calling from module.
Getting error argument not Optional. can you suggest whats wrong here. thanks.
Error line ------> If CheckMonth(str) = True Then
VBA Code:
Sub testMonths()
Dim dict As New Scripting.Dictionary
Dim s As String
s = "ABC USD 145,356 25jun2020 25Jun2020 18JUN2020 0.6 "
If CheckMonth(str) = True Then
dict.Add str, str
End If
End Sub
Function CheckMonth(ByVal str As String) As Boolean
Months = Array("JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC")
ns = UCase(s)
MCnt = 0
Do
FoundMonth = False
For Each MStr In Months
If InStr(ns, MStr) > 0 Then
FoundMonth = True
MCnt = MCnt + 1
ns = VBA.Replace(ns, MStr, "XXX", 1, 1)
If MCnt >= 3 Then
'dict.Add s, s
CheckMonth = True
Exit Sub
End If
End If
Next MStr
Loop Until Not FoundMonth
End Sub
Thanks
mg