IF Match function cannot detect the value in generates and error . In VBA I tried to catch this error use IsError() function but it can't detected the match error . how can I catch this Matching error in VBA?
Dim X As Long
Dim rng As Range
X = 35
Set rng = ActiveWorkbook.Worksheets(1).Range("D1:D6")
If IsError(WorksheetFunction.Match(X, rng, 0)) Then
Debug.Print "ERR"
Debug.Print WorksheetFunction.Match(X, rng, 0)
End If
Harassment is any behavior intended to disturb or upset a person or group of people. Threats include any threat of suicide, violence, or harm to another.
Any content of an adult theme or inappropriate to a community web site.
Any image, link, or discussion of nudity.
Any behavior that is insulting, rude, vulgar, desecrating, or showing disrespect.
Any behavior that appears to violate End user license agreements, including providing product keys or links to pirated software.
Unsolicited bulk mail or bulk advertising.
Any link to or advocacy of virus, spyware, malware, or phishing sites.
Any other inappropriate content or behavior as defined by the Terms of Use or Code of Conduct.
Any image, link, or discussion related to child pornography, child nudity, or other child abuse or exploitation.
Use Application.Match instead of WorksheetFunction.Match. Application.Match doesn't cause an error message but returns an error value if there is no match. So:
If IsError(Application.Match(X, rng, 0)) Then
---
Kind regards, HansV
https://www.eileenslounge.com
Harassment is any behavior intended to disturb or upset a person or group of people. Threats include any threat of suicide, violence, or harm to another.
Any content of an adult theme or inappropriate to a community web site.
Any image, link, or discussion of nudity.
Any behavior that is insulting, rude, vulgar, desecrating, or showing disrespect.
Any behavior that appears to violate End user license agreements, including providing product keys or links to pirated software.
Unsolicited bulk mail or bulk advertising.
Any link to or advocacy of virus, spyware, malware, or phishing sites.
Any other inappropriate content or behavior as defined by the Terms of Use or Code of Conduct.
Any image, link, or discussion related to child pornography, child nudity, or other child abuse or exploitation.