Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Find String in another string - only between spaces | Excel Worksheet Functions | |||
Find Many String options in ONE String | Excel Worksheet Functions | |||
search a string withing a string : find / search hangs | Excel Programming | |||
backwards find function to find character in a string of text | Excel Programming | |||
find a string inside another string | Excel Programming |