+ Reply to Thread
Results 1 to 7 of 7

Find method - finding multiple values

Hybrid View

  1. #1
    nathan
    Guest

    Find method - finding multiple values

    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.

  2. #2
    Jim Thomlinson
    Guest

    RE: Find method - finding multiple values

    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.


  3. #3
    nathan
    Guest

    RE: Find method - finding multiple values

    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.


  4. #4
    Tom Ogilvy
    Guest

    Re: Find method - finding multiple values

    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.




  5. #5
    nathan
    Guest

    Re: Find method - finding multiple values

    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.

    >
    >
    >


  6. #6
    John
    Guest

    RE: Find method - finding multiple values

    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.


  7. #7
    nathan
    Guest

    RE: Find method - finding multiple values

    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.


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1