A procedure analyzes data and builds a presentation out of it. If the data has not been properly processed (by other preceding methods in the excel sheet), the user should be redirected to complete that portion first. I am having trouble getting excel to redirect the user to the data which needs to be pre-processed. I want it to jump to the correct worksheet and highlight the row or cell. However it will not let me do this.
The code breaks out of a for loop to handle this error. The for loop has this basic skeletal structure:
Here is the offending code:
Run-time error '1004':
Application-defined or object defined error
I have tried using other methods and get the following errors:
Run-time error '1004': Select method of Range class failed
.Rows(I).Select
Run-time error '1004': Select method of Range class failed
.Cells(I, 1).Select
Run-time error '1004': Method 'Range' of object '_Global' failed
Range(.Cells(I, 1)).Select
Run-time error '1004': Application-defined or object defined error
.Range(.Cells(I, 1)).Select
Anyone know why it won't let me select the cell / row?
-JTBorton
Well, You can try banging your head against the wall, but you just end up with lost-time injuries and damaged equipment. [M. Passman]
The code breaks out of a for loop to handle this error. The for loop has this basic skeletal structure:
Code:
With [worksheet]
For I = 1 To EndofData
If Not .Cells(I, 4).Comment Is Nothing Then
[Analyze Data]
Else
[Handle Error & Redirect]
End If
Next I
End With
Here is the offending code:
Run-time error '1004':
Application-defined or object defined error
Code:
Redirect_To_PEP_Analysis:
With Worksheets("Master") [This worksheet is different from the loop above]
I = 3
Do
I = I + 1
If CLng(.Cells(I, 1)) = lngUPE_Num Then '(The cell matches the ID number)
[COLOR=green]'::::::::::::::::::::::::::: FLAG FOR DEBUG :::::::::::::::::::::::::::[/color]
[highlight].Range(.Rows(I)).Select 'Error Here[/highlight]
.Activate
Exit Do
ElseIf .Cells(I, 1) = "" Then
Exit Do
End If
Loop
End With
GoTo Proc_Exit
Proc_Exit:
Set wkshtPEP = Nothing
Exit Sub
I have tried using other methods and get the following errors:
Run-time error '1004': Select method of Range class failed
.Rows(I).Select
Run-time error '1004': Select method of Range class failed
.Cells(I, 1).Select
Run-time error '1004': Method 'Range' of object '_Global' failed
Range(.Cells(I, 1)).Select
Run-time error '1004': Application-defined or object defined error
.Range(.Cells(I, 1)).Select
Anyone know why it won't let me select the cell / row?
-JTBorton
Well, You can try banging your head against the wall, but you just end up with lost-time injuries and damaged equipment. [M. Passman]