Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi All I'm trying to query a string containing a list of operating systems types and return the operating system family to me. eg "Windows NT" is a member of "Windows" etc. The code below returms the correct result only when the string EXACTLY matches the code syntax, (including whitespaces, gaps, punctuation etc...) What syntax do I use if the string CONTAINS the pVal? I've tried "If pVal Like "Windows NT" Then...etc.. but it's not working.. I need something like "If pVAl contains "Windows" then Operating System = "Windows" Thanks Conor Code: -------------------- Function OperatingSystem(pVal As String) As String If pVal = "Windows 2000 Server SP4" Then OperatingSystem = "Windows" ElseIf pVal = "Windows NT" Then OperatingSystem = "Windows" Else OperatingSystem = "Other" End If End Function -------------------- -- okelly ------------------------------------------------------------------------ okelly's Profile: http://www.excelforum.com/member.php...o&userid=36708 View this thread: http://www.excelforum.com/showthread...hreadid=564641 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Function OperatingSystem(pVal As String) As String
If LCase(pVal) Like "*windows 2000*" Then OperatingSystem = "Windows" ElseIf LCase(pVal) Like "*windows nt*" Then OperatingSystem = "Windows" Else OperatingSystem = "Other" End If End Function -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "okelly" wrote in message ... Hi All I'm trying to query a string containing a list of operating systems types and return the operating system family to me. eg "Windows NT" is a member of "Windows" etc. The code below returms the correct result only when the string EXACTLY matches the code syntax, (including whitespaces, gaps, punctuation etc...) What syntax do I use if the string CONTAINS the pVal? I've tried "If pVal Like "Windows NT" Then...etc.. but it's not working.. I need something like "If pVAl contains "Windows" then Operating System = "Windows" Thanks Conor Code: -------------------- Function OperatingSystem(pVal As String) As String If pVal = "Windows 2000 Server SP4" Then OperatingSystem = "Windows" ElseIf pVal = "Windows NT" Then OperatingSystem = "Windows" Else OperatingSystem = "Other" End If End Function -------------------- -- okelly ------------------------------------------------------------------------ okelly's Profile: http://www.excelforum.com/member.php...o&userid=36708 View this thread: http://www.excelforum.com/showthread...hreadid=564641 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() cool, thanks -- okell ----------------------------------------------------------------------- okelly's Profile: http://www.excelforum.com/member.php...fo&userid=3670 View this thread: http://www.excelforum.com/showthread.php?threadid=56464 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Function OperatingSystem(pVal As String) As String If InStr(pVal, "Windows") Then OperatingSystem = "Windows" Else OperatingSystem = "Other" End if End Functio -- Kaa ----------------------------------------------------------------------- Kaak's Profile: http://www.excelforum.com/member.php...nfo&userid=751 View this thread: http://www.excelforum.com/showthread.php?threadid=56464 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Lookup text in a string with wildcard and return a certain value | Excel Worksheet Functions | |||
lookup a value within a text string | Excel Worksheet Functions | |||
lookup or find matching number in text string | Excel Worksheet Functions | |||
Search, find or lookup defined text in text string | Excel Worksheet Functions | |||
LOOKUP a text string created from IF statement | Excel Discussion (Misc queries) |