Dim and set
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.
--
David
"Zack Barresse" wrote:
... must have missed the End If when copying over, btw.
--
Regards,
Zack Barresse, aka firefytr
To email, remove NOSPAM
"Zack Barresse" wrote in message
...
Hello David,
You do not need to Set anything except Objects, which String is not. Here
is an example of what you could use ...
Dim rngCell As Range
Dim SerialNumber As String
SerialNumber = ActiveCell.Offset(1, 3).Value & ActiveCell.Offset(1,
4).Value
Set rngCell = Selection.Find(What:=SerialNumber, LookIn:=xlFormulas,
LookAt:=xlWhole)
If Not rngCell Is Nothing Then
rngCell.Activate
Else
MsgBox
HTH
--
Regards,
Zack Barresse, aka firefytr
To email, remove NOSPAM
"David" wrote in message
...
Hi Group,
I am having trouble with the follwing. When I try and find, it says it is
not set.
Dim SerialNumber As String
Set SerialNumber = ActiveCell.Offset(1, 3).Value & ActiveCell.Offset(1,
4).Value
Selection.Find(What:=SerialNumber, After:=ActiveCell, LookIn:=xlFormulas,
_
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
I tried the last statement with the Variable SerialNumber in ( ), but it
still says it is not set.
Thanks
--
David
.
|