Custom Function If..Else and reading text strings
I'm trying to write a function to read a string and depending on the
contents of that string assign a type to it. The code below is just an
example. I would use the IF function built-in to Excel but I have 15+
types and couple different ways to determine some of those types. This
is my first function.
When I use the following function, all I get is a '0' in the cell, not
even my error message. That makes me think that I'm using the StrComp
function incorrectly.
For sample data I'm using:
< 5KOLRAWAL1BI
< 2USSTVRVS1GI
< 5KOLTVWAL1BI
Function ReadAdCode(strAdCode As String)
Dim strAdType As String
If StrComp(strAdCode, "*5KOL*", vbTextCompare) = 0 Then
strAdType = "OTHER MEDIA"
ElseIf StrComp(strAdCode, "*TV*", vbTextCompare) = 0 Then
strAdType = "TVA"
Else
strAdType = "This is Not Working"
End If
End Function
Any help is greatly appreciated!
|