Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Wildcard operators to use with LIKE

Im using LIKE to determine if a cell contains certain text, but I dont know
how to use the wildcard characters or how to structure a pattern to make the
search effective.
I want to find any cell with the text traf10 in it not necessarily being
that string the only content of the cell.

If Cell2Srch.Value Like "traf10" And Not Cell2Srch.Value Like "traf106" Then
Cells(Cell2Srch.Row, 1).Value = "Yes"
End If

Thanks in advance

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Wildcard operators to use with LIKE

Hi,

Try this alternative to like

If InStr(cell2srch, "traf10") And Not InStr(cell2srch, "traf106") Then
Cells(cell2srch.Row, 1).Value = "Yes"

Mike

"LuisE" wrote:

Im using LIKE to determine if a cell contains certain text, but I dont know
how to use the wildcard characters or how to structure a pattern to make the
search effective.
I want to find any cell with the text traf10 in it not necessarily being
that string the only content of the cell.

If Cell2Srch.Value Like "traf10" And Not Cell2Srch.Value Like "traf106" Then
Cells(Cell2Srch.Row, 1).Value = "Yes"
End If

Thanks in advance

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 342
Default Wildcard operators to use with LIKE

I think the wild cards would make it look like this:

If Cell2Srch.Value Like "*traf10*" And Not Cell2Srch.Value Like "*traf106*"
Then
Cells(Cell2Srch.Row, 1).Value = "Yes"
End If

Tom
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Wildcard operators to use with LIKE

This should do the same thing PROVIDED there is always at least one
character following the 'traf10' characters...

If Cell2Srch.Value Like "*traf10[!6]*" Then

--
Rick (MVP - Excel)


"TomPl" wrote in message
...
I think the wild cards would make it look like this:

If Cell2Srch.Value Like "*traf10*" And Not Cell2Srch.Value Like
"*traf106*"
Then
Cells(Cell2Srch.Row, 1).Value = "Yes"
End If

Tom


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Wildcard operators to use with LIKE

I guess this version will work properly even if there is no character
following the 'traf10' characters...

If Cell2Srch.Value & " " Like "*traf10[!6]*" Then

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
This should do the same thing PROVIDED there is always at least one
character following the 'traf10' characters...

If Cell2Srch.Value Like "*traf10[!6]*" Then

--
Rick (MVP - Excel)


"TomPl" wrote in message
...
I think the wild cards would make it look like this:

If Cell2Srch.Value Like "*traf10*" And Not Cell2Srch.Value Like
"*traf106*"
Then
Cells(Cell2Srch.Row, 1).Value = "Yes"
End If

Tom



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
Using Or and And Operators RyanH Excel Programming 2 August 26th 08 12:57 AM
combining operators ezil Excel Programming 3 July 23rd 07 06:46 PM
Operators/if etc Peter[_61_] Excel Programming 4 December 18th 06 11:11 AM
Comparison Operators Devanath Ong Excel Programming 2 June 22nd 06 03:16 PM
Unary operators Joe Excel Worksheet Functions 3 February 14th 05 06:09 PM


All times are GMT +1. The time now is 12:45 AM.

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"