Hi,
Remove the Activate method when you are making an assignment.
Set rngFound = Cells.Find(What:="9C4754", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
Cheers
Andy
David wrote:
I am still failing and I guess it is because I have not enclosed all the
code, so the problems must be somewhere else:
Sub TaylorFarm()
' Macro1 Macro
' Macro recorded 3/23/2006 by David Lanman
Range("A1").Select
Dim SerialNumber As String
Dim rngFound As Range
Cells.Find(What:="Equipment", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
EquipmentID = ActiveCell.Offset(1, 0).Value
If EquipmentID = "" Then
SerialNumber = ActiveCell.Offset(1, 3).Value & ActiveCell.Offset(1,
4).Value
Sheets("TAYLORSerNo").Select
Range("A1").Select
Set rngFound = Cells.Find(What:="9C4754", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
If rngFound Is Nothing Then
MsgBox "Sorry, not found"
Else
rngFound.Select
End If
Else
Stop
End If
Cells.FindNext(After:=ActiveCell).Activate
End Sub
It fails when I try and do the Find "Set rngFound =". It is hardcoded here,
but I would be using the variable SerialNumber.
Thanks for your help.
--
Andy Pope, Microsoft MVP - Excel
http://www.andypope.info