The problem is when the Find function doesn't find anything. If nothin
is found, the error is generated. The way around it is to use an erro
handler:
Sub Macro1()
Dim i As Integer
Dim FoundIt
For i = 1 To 1000
Columns("A:A").Select
ON ERROR RESUME NEX
FoundIt = Selection.Find(What:=i, _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False).Activate
[b]'Here you can check for an error and do what you need to do
If Err.Number < 0 Then
'Do something
End If
i = i + 1
Next
End Sub
--
kkkni
-----------------------------------------------------------------------
kkknie's Profile:
http://www.excelforum.com/member.php...nfo&userid=754
View this thread:
http://www.excelforum.com/showthread.php?threadid=26694