#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Find String

Hello!,


By using the find option we could search for part of a cell or whole
cell content.

But if it possible to search using wild cards starting from the
beginning of the cell?

Like match the starting charecters only...

Tra* will find TRAvel, TRAnsport, TRAde etc but not cenTRAl or conTRAct
?!!!

THANKS

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Find String

Try it and see.

--
HTH

Bob Phillips

(replace somewhere in email address with googlemail if mailing direct)

"Abdul" wrote in message
oups.com...
Hello!,


By using the find option we could search for part of a cell or whole
cell content.

But if it possible to search using wild cards starting from the
beginning of the cell?

Like match the starting charecters only...

Tra* will find TRAvel, TRAnsport, TRAde etc but not cenTRAl or conTRAct
?!!!

THANKS



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Find String

Sorry, I think I did'nt make it clear..

I want to search part of a cell starting from the first character
only.. So that TRA* will find TRAvel, TRAnsport, TRAde etc but it
should exclude cenTRAl or conTRAct since it does not start with TRA

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Find String

Hi Abdul,

Try setting the Find method's LookAt parameter to XlWhole.

For example (lightly adapting the Help example code):

'=============
Public Sub Tester001()
Dim rng As Range
Dim firstAddress As String
Const searchStr As String = "Tra*"

With ActiveSheet.Cells
Set rng = .Find(searchStr, _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
firstAddress = rng.Address
Do
rng.Interior.ColorIndex = 6
Set rng = .FindNext(rng)
Loop While Not rng Is Nothing _
And rng.Address < firstAddress
End If
End With

End Sub
'<<=============

If I ran the above code on a sheet which contained multiple examples of all
of your suggested words, only those words that commenced with the letters
'tra' were highlighted.

---
Regards,
Norman



"Abdul" wrote in message
oups.com...
Sorry, I think I did'nt make it clear..

I want to search part of a cell starting from the first character
only.. So that TRA* will find TRAvel, TRAnsport, TRAde etc but it
should exclude cenTRAl or conTRAct since it does not start with TRA

Thanks



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 String in another string - only between spaces Nir Excel Worksheet Functions 9 November 2nd 06 11:31 AM
Find Many String options in ONE String Nir Excel Worksheet Functions 6 October 26th 06 07:13 AM
search a string withing a string : find / search hangs itarnak[_9_] Excel Programming 4 October 24th 05 03:19 PM
backwards find function to find character in a string of text Ashleigh K. Excel Programming 1 January 14th 04 04:36 PM
find a string inside another string MarkS Excel Programming 1 January 13th 04 02:55 AM


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