View Single Post
  #11   Report Post  
JE McGimpsey
 
Posts: n/a
Default

If you're sure that the value exists in the selection, you can use
something like:

Selection.Find( _
What:=Sheets("Sheet2").Range("A1").Value, _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:= False).Activate


However, if it doesn't, you'll get an error. You can use a variable to
check if it exists:

Dim rFound As Range
Set rFound = Selection.Find( _
What:=Sheets("Sheet2").Range("A1").Value, _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:= False)
If rFound Is Nothing Then
MsgBox """" & Sheets("Sheet2").Range("A1").Value & _
""" was not found."
Else
rFound.Activate
End If




In article ,
Robert AS wrote:

When I record a macro with the find function I get this

Selection.Find(What:="874", After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate

What I need to do is replace the "874" with a value on sheet 2 and find the
value in sheet 1.......But I don't know how to do that. I've tried about
everything I know and I get nothing that works. Things like
Sheets("Sheet2").Range("A1").value....... calling it MyFindValue

Nothing been at this for weeks now

How can I get the macro to reead a value in sheet 2 to activate the same
value in sheet 1? If I can get that to work I can get the rest of it to work.
The macro is recorded as relative.

I'm sure there is a way to get it to read the cell in sheet 2 I'm just not
getting it....please help. This is part of a much bigger problem and the only
pitfall I have.

Bob