theduckman16
New Member
- Joined
- Feb 4, 2011
- Messages
- 16
Hello -
I am having an issue with run-time 91 errors trying to search for text in a column.
Here is what I am trying to do and where my problems are occurring:
Copy text in sheet 1
go to sheet 2 and search for that text
if the text is found, my macro goes to another column, copies that value and pastes it in sheet 1 in another column.
if the text is not found, I get an error.
I have an clear error section right now, but if I get two consecutive errors the macro will stop.
Here is my code:
Thank you for your help
I am having an issue with run-time 91 errors trying to search for text in a column.
Here is what I am trying to do and where my problems are occurring:
Copy text in sheet 1
go to sheet 2 and search for that text
if the text is found, my macro goes to another column, copies that value and pastes it in sheet 1 in another column.
if the text is not found, I get an error.
I have an clear error section right now, but if I get two consecutive errors the macro will stop.
Here is my code:
Code:
Sub Macro1()
'
' Macro1 Macro
'
'
For i = 2 To Rows.Count
Dim j As String
Dim k As Range
On Error GoTo Err_Clk
If ActiveCell.Value = "" Then
ActiveCell.Offset(1, 0).Select
End If
j = ActiveCell.Value
Selection.Copy
ActiveSheet.Next.Select
Range("A1").Select
Cells.Find(What:=j, After:=ActiveCell _
, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(0, 7).Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Previous.Select
ActiveCell.Offset(0, -9).Select
ActiveSheet.Paste
ActiveCell.Offset(1, 9).Select
Err_Clk:
If Err.Number <> 0 Then
Err.Clear
ActiveSheet.Previous.Select
ActiveCell.Offset(1, 0).Select
End If
Next i
End Sub
Last edited: