View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Charles Charles is offline
external usenet poster
 
Posts: 1
Default Runtime error 91

Reiner
ERR 91 is because the value you are looking for is not in the rang
selected. Below I added Resume Next if the value is not found a msgbo
will be displayed showing you the value not found.

HTH

Charles



Sub Makro5()
'
Dim ID As Integer

Range("D1").Select
ID = Range("D1").Value
Columns("B:B").Select
On Error Resume Next
Selection.Find(What:=ID, After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False).Activate
If Err = 91 Then
MsgBox "Could not find " & ID
Exit Sub
End If
ActiveCell.Offset(0, 1).Activate
ActiveCell.Select
Selection.Copy

Range("F1").Select
ActiveSheet.Paste

End Su

--
Message posted from http://www.ExcelForum.com