LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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!

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
find and replace numeric strings in larger text strings Mr Molio Excel Worksheet Functions 8 November 9th 11 05:17 PM
=IF function, reference problem to "text strings" in Data Validati Jim D.[_2_] Excel Discussion (Misc queries) 2 July 17th 09 08:56 AM
How to refer to a text piece in a VBA custom function? FARAZ QURESHI Excel Discussion (Misc queries) 2 January 27th 08 03:11 PM
Custom number formats in TEXT function MatthewB Excel Worksheet Functions 4 June 28th 06 09:05 PM
Reading long strings (with jdbc) from Excel Aaron Fude Excel Programming 4 November 15th 04 12:56 PM


All times are GMT +1. The time now is 11:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"