PC Review


Reply
Thread Tools Rate Thread

case is string contains string?

 
 
salgud
Guest
Posts: n/a
 
      22nd Mar 2010
I have played with it for an hour, but can't figure out how to make a case
statement that would be something like:

Case is = (string1 contains string2)

Is there a way to do this?
Thanks!
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      22nd Mar 2010
Look in the vba help index for
INSTR

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"salgud" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have played with it for an hour, but can't figure out how to make a case
> statement that would be something like:
>
> Case is = (string1 contains string2)
>
> Is there a way to do this?
> Thanks!


 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      22nd Mar 2010
simplistic, but may give you an idea, since you didn't provide much.

Sub test()
Select Case True
Case InStr(1, "this is a test", "tst")
Debug.Print "True"
Case Else
Debug.Print "False"
End Select
End Sub


--


Gary Keramidas
Excel 2003


"salgud" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have played with it for an hour, but can't figure out how to make a case
> statement that would be something like:
>
> Case is = (string1 contains string2)
>
> Is there a way to do this?
> Thanks!


 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      22nd Mar 2010
Try

Select Case True

Case string1 Like "*string2*"

etc.
End Select

--

HTH

Bob

"salgud" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have played with it for an hour, but can't figure out how to make a case
> statement that would be something like:
>
> Case is = (string1 contains string2)
>
> Is there a way to do this?
> Thanks!



 
Reply With Quote
 
salgud
Guest
Posts: n/a
 
      23rd Mar 2010
On Mon, 22 Mar 2010 16:29:40 -0600, salgud wrote:

> I have played with it for an hour, but can't figure out how to make a case
> statement that would be something like:
>
> Case is = (string1 contains string2)
>
> Is there a way to do this?
> Thanks!


Thanks to all!
 
Reply With Quote
 
salgud
Guest
Posts: n/a
 
      23rd Mar 2010
On Tue, 23 Mar 2010 07:38:15 -0600, salgud wrote:

> On Mon, 22 Mar 2010 16:29:40 -0600, salgud wrote:
>
>> I have played with it for an hour, but can't figure out how to make a case
>> statement that would be something like:
>>
>> Case is = (string1 contains string2)
>>
>> Is there a way to do this?
>> Thanks!

>
> Thanks to all!


Gave both methods a try, but neither works! I'm setting a case for
worksheets that have "Monthly" in their sheetname (sWsName)

I put in:

Case sWsName like "Monthly"

and

Case "Monthly" Like sWsName

and

Case instr(1,lcase(sWsName),"monthly")

and

Case InStr(1, sWsName, "Monthly")

Am I missing something?
 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      23rd Mar 2010
Not much point us answering if you don't read it

Case sWsName like "*Monthly*"


--

HTH

Bob

"salgud" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Tue, 23 Mar 2010 07:38:15 -0600, salgud wrote:
>
>> On Mon, 22 Mar 2010 16:29:40 -0600, salgud wrote:
>>
>>> I have played with it for an hour, but can't figure out how to make a
>>> case
>>> statement that would be something like:
>>>
>>> Case is = (string1 contains string2)
>>>
>>> Is there a way to do this?
>>> Thanks!

>>
>> Thanks to all!

>
> Gave both methods a try, but neither works! I'm setting a case for
> worksheets that have "Monthly" in their sheetname (sWsName)
>
> I put in:
>
> Case sWsName like "Monthly"
>
> and
>
> Case "Monthly" Like sWsName
>
> and
>
> Case instr(1,lcase(sWsName),"monthly")
>
> and
>
> Case InStr(1, sWsName, "Monthly")
>
> Am I missing something?



 
Reply With Quote
 
salgud
Guest
Posts: n/a
 
      23rd Mar 2010
On Tue, 23 Mar 2010 19:19:10 -0000, Bob Phillips wrote:

> Not much point us answering if you don't read it
>
> Case sWsName like "*Monthly*"


Thanks for your help.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I check if a letter in a string is upper case or lower case ? fniles Microsoft VB .NET 14 7th Apr 2007 03:45 PM
how to make two references to one string that stay refered to the same string reguardless of the changing value in the string? Daniel Microsoft Dot NET 7 12th Nov 2004 09:08 AM
how to make two references to one string that stay refered to the same string reguardless of the changing value in the string? Daniel Microsoft C# .NET 10 3rd Nov 2004 03:26 PM
Cannot create an object of type 'System.String[]' from its string representation 'String[] Array' for the 'Options' property. Hessam Microsoft C# .NET 0 8th Aug 2003 09:45 AM
Re: Converting a string to a string that contains the ASCII values of each letter in the origional string Jon Skeet Microsoft C# .NET 0 31st Jul 2003 08:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:32 AM.