Bonediggler
Technical User
Hi--
This is another question related to the code posted in the "Error Handler Only Works Once" thread.
I implemented the suggestions provided regarding the error handler and made some additional necessary tweaks to the code.
The problem I am having now is that the outer loop goes to "exit sub" after the 3rd round instead of passing in the next value.
Here is the code (minus variable assignments):
On Error GoTo ErrorHandler
For k = a To b
Worksheets(k).Activate
For i = DNIS1 To DNIS4
If i = 3781 Then i = 3797
Cells.Find(i).Activate
Set x = ActiveCell
Set y = ActiveCell.End(xlToRight)
Range(x, y).Copy
Worksheets("End").Activate
If k = a Then p = 3
If k = q Then p = 4
If k = b Then p = 5
If k = n Then p = 6
If k = m Then p = 7
If k = g Then p = 8
If k = u Then p = 9
Cells.Find(i).Offset(p, 1).PasteSpecial
Worksheets(k).Activate
Nexti:
Next i
Nextk:
Next k
Exit Sub
ErrorHandler:
If i = 3778 Then Resume Nexti
If i = 3779 Then Resume Nexti
If i = 3780 Then Resume Nexti
If i = 3797 Then Resume Nextk
End Sub
This is another question related to the code posted in the "Error Handler Only Works Once" thread.
I implemented the suggestions provided regarding the error handler and made some additional necessary tweaks to the code.
The problem I am having now is that the outer loop goes to "exit sub" after the 3rd round instead of passing in the next value.
Here is the code (minus variable assignments):
On Error GoTo ErrorHandler
For k = a To b
Worksheets(k).Activate
For i = DNIS1 To DNIS4
If i = 3781 Then i = 3797
Cells.Find(i).Activate
Set x = ActiveCell
Set y = ActiveCell.End(xlToRight)
Range(x, y).Copy
Worksheets("End").Activate
If k = a Then p = 3
If k = q Then p = 4
If k = b Then p = 5
If k = n Then p = 6
If k = m Then p = 7
If k = g Then p = 8
If k = u Then p = 9
Cells.Find(i).Offset(p, 1).PasteSpecial
Worksheets(k).Activate
Nexti:
Next i
Nextk:
Next k
Exit Sub
ErrorHandler:
If i = 3778 Then Resume Nexti
If i = 3779 Then Resume Nexti
If i = 3780 Then Resume Nexti
If i = 3797 Then Resume Nextk
End Sub