Issues using Nested Functions embedded in EXCEL VBA code
I am receiveing RUN-TIME error 424 - Object Required errors when using nested functions within my EXCEL VBA Code.
The code is attempting to read a text string and extract 3 characters from within that string.
There are 4 possible sets of character outcomes I am looking to obtain.
When I embed the formula within a spreadsheet cell it works. It does not work within the VBA code.
Here is a sample of my code:
Sub MacroSearch()
Dim Res As Variant
Dim FName As Variant
FName = "Application.WorksheetFunction"
Res = FName.IfError(Mid(C3, FName.Search("RDP", C3), 3), _
FName.IfError(Mid(C3, FName.Search("SG1", C3), 3), _
FName.IfError(Mid(C3, FName.Search("VO", C3), 2), _
FName.IfError(Mid(C3, FName.Search("VPN", C3), 3), "No Match"))))
End Sub
What I want the code to do is to extract embedded acronyms in a string of characters in column "C" for a range of rows. In the above sample code I am using only one row to simplify the question. However, I plan to use it against hundreds of rows, which will mean I would have to modify the cell references to be relative rather than absolute.
The error indicates that I am not attaching the functions to an object.
I thought I done that by the use of the variable FName.
I am thinking that I need an object reference for the IfError value "No Match", but do not know how to do that.
Another question, does this code need to set an active cell to write out the string "No Match"? I want to evaluate strings in Column "C" and write out the results into Column "D" if the characters are found embedded in the string.
I would appreciate any help I can get.
Thanks in Advance
Joe
Recent comments
5 years 36 weeks ago
6 years 22 weeks ago
6 years 34 weeks ago
6 years 37 weeks ago
6 years 38 weeks ago
6 years 43 weeks ago
6 years 52 weeks ago
7 years 2 days ago
7 years 3 days ago
7 years 3 days ago