![]() |
Runtime error 91
Hi, all
on the macro der Wert "ID" in Column "b" is not available the Error Message pop up Runtimeerrot 91 Objectvariable or With-Blockvariable not set. Sub Makro5() ' Dim ID As Integer Range("D1").Select ID = Range("D1") Columns("B:B").Select Selection.Find(what:=ID, After:=ActiveCell, LookIn:=xlValues, LookAt _ :=xlWhole, SearchOrder:=xlByColumns,SearchDirection:=xlNext,M atchCase_ :=False, SearchFormat:=False).Activate ActiveCell.Offset(0, 1).Activate ActiveCell.Select Selection.Copy Range("F1").Select ActiveSheet.Paste End Sub Thanks Reiner |
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 |
All times are GMT +1. The time now is 07:44 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com