Dim and set
Set is only required when you are referencing objects like range objects or
whape objects. In your case SerialNumber is a regualr variable (string, or
integer or double), so set is not required. However if your find does not
find what it is looking for the code will crash. This is where you would want
to set a range object
Dim SerialNumber As String
Dim rngFound as Range
SerialNumber = ActiveCell.Offset(1, 3).Value & ActiveCell.Offset(1, 4).Value
set rngFound = Selection.Find(What:=SerialNumber, After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
if rngfound is nothing then
msgbox "Sorry, not found"
else
rngfound.select
enid if
--
HTH...
Jim Thomlinson
"David" wrote:
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
|