Is there simple way to use "find" to search for more than one string? i.e.
find "b" or find "s", without running separate a "find" code for each string.
this doesn't work, but explains what I want to do: .find(what:="b" or "s")
thanks again.
Is there simple way to use "find" to search for more than one string? i.e.
find "b" or find "s", without running separate a "find" code for each string.
this doesn't work, but explains what I want to do: .find(what:="b" or "s")
thanks again.
Nope and there would be no real point to it. The find function finding all
instances of B and then finding all of the instances of S would be the same
as finding all of the instaces of B or S. It would not be any more efficient
one way or the other becuase the find has to do the exact same amount of work
finding all instances of B and all instance of S.
--
HTH...
Jim Thomlinson
"nathan" wrote:
> Is there simple way to use "find" to search for more than one string? i.e.
> find "b" or find "s", without running separate a "find" code for each string.
> this doesn't work, but explains what I want to do: .find(what:="b" or "s")
>
> thanks again.
I'm trying to keep the code writing effecient, clear and down to a minimum.
thanks.
"Jim Thomlinson" wrote:
> Nope and there would be no real point to it. The find function finding all
> instances of B and then finding all of the instances of S would be the same
> as finding all of the instaces of B or S. It would not be any more efficient
> one way or the other becuase the find has to do the exact same amount of work
> finding all instances of B and all instance of S.
> --
> HTH...
>
> Jim Thomlinson
>
>
> "nathan" wrote:
>
> > Is there simple way to use "find" to search for more than one string? i.e.
> > find "b" or find "s", without running separate a "find" code for each string.
> > this doesn't work, but explains what I want to do: .find(what:="b" or "s")
> >
> > thanks again.
no. But then how hard is it to put the strings in an array and loop through
the strings?
Regards,
Tom Ogilvy
"nathan" <nathan@discussions.microsoft.com> wrote in message
news:2D765700-52B0-4912-BAB4-CF1825357765@microsoft.com...
> Is there simple way to use "find" to search for more than one string?
i.e.
> find "b" or find "s", without running separate a "find" code for each
string.
> this doesn't work, but explains what I want to do: .find(what:="b" or
"s")
>
> thanks again.
if that is a way to do it, then that is what I am looking for help on. looks
like john showed an example of that. thanks.
"Tom Ogilvy" wrote:
> no. But then how hard is it to put the strings in an array and loop through
> the strings?
>
> Regards,
> Tom Ogilvy
>
> "nathan" <nathan@discussions.microsoft.com> wrote in message
> news:2D765700-52B0-4912-BAB4-CF1825357765@microsoft.com...
> > Is there simple way to use "find" to search for more than one string?
> i.e.
> > find "b" or find "s", without running separate a "find" code for each
> string.
> > this doesn't work, but explains what I want to do: .find(what:="b" or
> "s")
> >
> > thanks again.
>
>
>
Nathan
try something like this...
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range
Dim WhatToFind As Variant
Dim iCtr As Long
Dim DestCell As Range
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Set wks = Sheets("sheetname")
Set rngToSearch = wks.Columns(6)
WhatToFind = Array("1", "2", "3")
For iCtr = LBound(WhatToFind) To UBound(WhatToFind)
With rngToSearch
Set rngFound = .Cells.Find(what:=WhatToFind(iCtr), _
LookIn:=xlValues, lookat:=xlWhole, _
after:=.Cells(.Cells.Count), _
MatchCase:=False)
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
"nathan" wrote:
> Is there simple way to use "find" to search for more than one string? i.e.
> find "b" or find "s", without running separate a "find" code for each string.
> this doesn't work, but explains what I want to do: .find(what:="b" or "s")
>
> thanks again.
thanks.
"John" wrote:
> Nathan
>
> try something like this...
>
> Dim rngToSearch As Range
> Dim wks As Worksheet
> Dim rngFound As Range
> Dim WhatToFind As Variant
> Dim iCtr As Long
> Dim DestCell As Range
>
> Application.ScreenUpdating = False
> Application.Calculation = xlCalculationManual
>
> Set wks = Sheets("sheetname")
> Set rngToSearch = wks.Columns(6)
>
> WhatToFind = Array("1", "2", "3")
>
> For iCtr = LBound(WhatToFind) To UBound(WhatToFind)
> With rngToSearch
> Set rngFound = .Cells.Find(what:=WhatToFind(iCtr), _
> LookIn:=xlValues, lookat:=xlWhole, _
> after:=.Cells(.Cells.Count), _
> MatchCase:=False)
> Application.ScreenUpdating = True
> Application.Calculation = xlCalculationAutomatic
>
>
> "nathan" wrote:
>
> > Is there simple way to use "find" to search for more than one string? i.e.
> > find "b" or find "s", without running separate a "find" code for each string.
> > this doesn't work, but explains what I want to do: .find(what:="b" or "s")
> >
> > thanks again.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks