#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default strings

Hi, In range("a1") I have '20 Points - 5 Card Charlie' or '20 Points -
Black Jack'. The 'x Points -' can be any number. How do I ask in vba
does the sting contain '5 Card Charlie' or 'Black Jack'
Regards Robert

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default strings

one way:
=if(countif(a1,"*5 card charlie*")0,"Found it","nope")

or
=if(isnumber(search("5 card charlie",a1)),"yep","nope")

You could use Find (instead of Search) if you wanted case sensitive results.

RobcPettit wrote:

Hi, In range("a1") I have '20 Points - 5 Card Charlie' or '20 Points -
Black Jack'. The 'x Points -' can be any number. How do I ask in vba
does the sting contain '5 Card Charlie' or 'Black Jack'
Regards Robert


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default strings

Thankyou for your reply. This is great for in the worksheet, but i need
to do it in vba.
Regards Robert
Dave Peterson wrote:
one way:
=if(countif(a1,"*5 card charlie*")0,"Found it","nope")

or
=if(isnumber(search("5 card charlie",a1)),"yep","nope")

You could use Find (instead of Search) if you wanted case sensitive results.

RobcPettit wrote:

Hi, In range("a1") I have '20 Points - 5 Card Charlie' or '20 Points -
Black Jack'. The 'x Points -' can be any number. How do I ask in vba
does the sting contain '5 Card Charlie' or 'Black Jack'
Regards Robert


--

Dave Peterson


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default strings

Solved it. Used
If InStr(Range("c13"), "5 Card Charlie") Then
charlie = "5CC"
Else
charlie = ""
End If

Thankyou Regards Robert

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default strings

Oops. Sorry about missing the VBA stuff.

You may want to use something like:

If InStr(1, ActiveSheet.Range("c13").Value, _
"5 card charlie", vbTextCompare) 0 Then

if you don't care about case.

(and I like to qualify my ranges...)

RobcPettit wrote:

Solved it. Used
If InStr(Range("c13"), "5 Card Charlie") Then
charlie = "5CC"
Else
charlie = ""
End If

Thankyou Regards Robert


--

Dave Peterson
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
find and replace numeric strings in larger text strings Mr Molio Excel Worksheet Functions 8 November 9th 11 05:17 PM
How to find number of pairs of strings from list of strings? greg_overholt Excel Worksheet Functions 5 January 27th 06 10:42 PM
How can I count strings within strings Paul W Excel Worksheet Functions 4 June 14th 05 12:39 PM
Finding strings within strings Rod[_6_] Excel Programming 1 December 2nd 03 05:34 PM
Finding strings within strings Rod[_6_] Excel Programming 1 December 2nd 03 05:19 PM


All times are GMT +1. The time now is 04:16 PM.

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

About Us

"It's about Microsoft Excel"