Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Lookup String in Text


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Lookup String in Text

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Lookup String in Text


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Lookup String in Text


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
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
Lookup text in a string with wildcard and return a certain value Tommy Excel Worksheet Functions 4 September 25th 08 06:21 PM
lookup a value within a text string Henrik Excel Worksheet Functions 5 March 12th 08 01:10 PM
lookup or find matching number in text string mmanis Excel Worksheet Functions 3 October 3rd 07 03:59 PM
Search, find or lookup defined text in text string zzxxcc Excel Worksheet Functions 9 September 6th 07 09:37 PM
LOOKUP a text string created from IF statement Steve-in-austin Excel Discussion (Misc queries) 0 May 11th 06 09:10 PM


All times are GMT +1. The time now is 12:15 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"