View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
p45cal[_50_] p45cal[_50_] is offline
external usenet poster
 
Posts: 107
Default Searching certain ranges and stopping when finding no match

I'm sorry I didn't check all the code. Remove:

..Activate from the "set c = " line

and

After:=ActiveCell,

because the active cell isn't in the range.


This shoul leave you with something like this:

x = ActiveCell
Set c = Range("G1:G7").Find(What:=x, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=False)
If Not c Is Nothing Then
c.Activate
Else
Exit Sub
End If

--
p45cal


" wrote:

I think I added what both of you have said, and I'm getting a type
mismatch error on the Set c = ... line. Any suggestions? (Thanks again
for the help everyone, I really appreciate it.)

Selection.Copy
x = ActiveCell
Windows("VOD Master List as of 06-19-07.xls").Activate
Set c = Range("G1:G4").Find(What:=x, After:=ActiveCell,
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, MatchCase:=False,
SearchFormat:=False).Activate
If Not c Is Nothing Then
c.Activate
Else
Exit Sub
End If

On Jul 5, 12:42 pm, p45cal wrote:
I suspect that

set x = range("G1:G5000")l
Windows("VOD Master List as of 06-19-07.xls").Activate
set c = Cells.Find(What:=x, After:=ActiveCell, LookIn:=xlFormulas...

should be

set x = activecell
Windows("VOD Master List as of 06-19-07.xls").Activate
set c = range("G1:G5000").Find(What:=x, After:=ActiveCell,
LookIn:=xlFormulas ...
--
p45cal