Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Trying to limit .Find to a specific range

I am trying to find occurances of value within a range of cells.
Could someone help me with this code?

tia

For Each rngMyCell In rngMyRange
With Cells
Set rngMyCell = .Find(What:=strEdit_Find, After:=ActiveCell,_
LookIn:=xlValues, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)
If Not rngMyCell Is Nothing Then
strFirstAddress = rngMyCell.Address
Do
strData = rngMyCell.Formula
lCountValueReplaces = lCountValueReplaces + 1
Set rngMyCell = .FindNext(rngMyCell)
Loop While Not rngMyCell Is Nothing And ngMyCell.Address
< strFirstAddress
End If
End With
Next




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Trying to limit .Find to a specific range

Hi:

Instead of:

With Cells

use:

With Range("A1:Z100") 'or whatever

Regards,

Vasant.

wrote in message
...
I am trying to find occurances of value within a range of cells.
Could someone help me with this code?

tia

For Each rngMyCell In rngMyRange
With Cells
Set rngMyCell = .Find(What:=strEdit_Find, After:=ActiveCell,_
LookIn:=xlValues, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)
If Not rngMyCell Is Nothing Then
strFirstAddress = rngMyCell.Address
Do
strData = rngMyCell.Formula
lCountValueReplaces = lCountValueReplaces + 1
Set rngMyCell = .FindNext(rngMyCell)
Loop While Not rngMyCell Is Nothing And ngMyCell.Address
< strFirstAddress
End If
End With
Next






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Trying to limit .Find to a specific range

Dim rngMyRange as Range
Dim rngMyCell as Range
Dim strFirstAddress as String
Dim strEdit_Find as String
Dim strData as String
Dim lCountValueReplaces as Long
With rngMyRange
Set rngMyCell = .Find(What:=strEdit_Find, _
After:=rngMyRange(rng.MyRange.count), _
LookIn:=xlValues, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)
If Not rngMyCell Is Nothing Then
strFirstAddress = rngMyCell.Address
Do
strData = strData & rngMyCell.Formula & vbNewLine
lCountValueReplaces = lCountValueReplaces + 1
Set rngMyCell = .FindNext(rngMyCell)
Loop While Not rngMyCell Is Nothing And _
rngMyCell.Address < strFirstAddress
End If
End With
msgbox strData

Your not doing any replacing, so I am not sure what you want out of
lcountValueReplaces

It will count the number cells found containing strEdit_Find

--
Regards,
Tom Ogilvy


wrote in message
...
I am trying to find occurances of value within a range of cells.
Could someone help me with this code?

tia

For Each rngMyCell In rngMyRange
With Cells
Set rngMyCell = .Find(What:=strEdit_Find, After:=ActiveCell,_
LookIn:=xlValues, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)
If Not rngMyCell Is Nothing Then
strFirstAddress = rngMyCell.Address
Do
strData = rngMyCell.Formula
lCountValueReplaces = lCountValueReplaces + 1
Set rngMyCell = .FindNext(rngMyCell)
Loop While Not rngMyCell Is Nothing And ngMyCell.Address
< strFirstAddress
End If
End With
Next






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Trying to limit .Find to a specific range

Thanks, that worked perfectly


On Sun, 2 Nov 2003 15:42:14 -0600, "Chip Pearson"
wrote:

Bill,

Just change
With Cells
to
With Range("A1:A10")

or whatever range you want to search.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Trying to limit .Find to a specific range

If that is all you changed, you are wasting a lot of time in your code. You
are also changing your loop variable within the loop which is not
recommended, but you don't need the loop anyway.


--
Regards,
Tom Ogilvy


wrote in message
...
Thanks, that worked perfectly


On Sun, 2 Nov 2003 15:42:14 -0600, "Chip Pearson"
wrote:

Bill,

Just change
With Cells
to
With Range("A1:A10")

or whatever range you want to search.




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 & Replace - Limit search to a specific column falena23 Excel Worksheet Functions 3 July 28th 08 03:46 PM
Limit Printing on specific worksheets in Excel [email protected] Excel Discussion (Misc queries) 2 May 28th 07 01:48 PM
Find the bottom cell that contains a specific val in a range? amit Excel Worksheet Functions 2 January 24th 07 05:23 PM
find sum if one col = ? within specific date range jrheinschm Excel Discussion (Misc queries) 8 July 5th 06 09:48 PM
find numbers in a range that add to a specific value Brett Excel Discussion (Misc queries) 1 December 20th 04 01:55 PM


All times are GMT +1. The time now is 02:01 PM.

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"