Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default 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
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
Finding multiple data values in a column PeteJ Excel Worksheet Functions 2 September 15th 09 07:16 PM
finding multiple non-zero values in a column ij00mini Excel Worksheet Functions 2 February 19th 08 11:21 PM
finding multiple non-zero values in a column ij00mini Excel Worksheet Functions 2 January 29th 08 02:55 PM
Finding multiple values of a function trainerbro Excel Worksheet Functions 3 November 6th 06 08:09 PM
Finding (Multiple) Highest Values in Column Shay Hurley Excel Worksheet Functions 1 October 3rd 05 04:19 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"