Runtime error 91

R

Reiner

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,MatchCase_
:=False, SearchFormat:=False).Activate

ActiveCell.Offset(0, 1).Activate
ActiveCell.Select
Selection.Copy

Range("F1").Select
ActiveSheet.Paste

End Sub


Thanks
Reiner
 
F

Frank Kabel

Hi
use
Sub Makro5()
'
Dim IDrng As range
Dim ID

Range("D1").Select
set IDrng = Range("D1")
ID=IDrng.value
Columns("B:B").Select
 
J

Jim Rech

Sub Test()
Dim FoundCell As Range
On Error Resume Next
Set FoundCell = Range("B:B").Find(Range("D1").Value)
If Not FoundCell Is Nothing Then
FoundCell.Offset(0, 1).Copy Range("F1")
End If
End Sub


--
Jim Rech
Excel MVP
| 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,MatchCase_
| :=False, SearchFormat:=False).Activate
|
| ActiveCell.Offset(0, 1).Activate
| ActiveCell.Select
| Selection.Copy
|
| Range("F1").Select
| ActiveSheet.Paste
|
| End Sub
|
|
| Thanks
| Reiner
 
R

Reinhold Klein

Jim said:
Sub Test()
Dim FoundCell As Range
On Error Resume Next
Set FoundCell = Range("B:B").Find(Range("D1").Value)
If Not FoundCell Is Nothing Then
FoundCell.Offset(0, 1).Copy Range("F1")
End If
End Sub
Thanks

it's easy but it's works

Reiner
 
Top