Code:
desLastRow.Row <> desSheet.Cells(desSheet.Rows.count, "F").End(xlUp).Row
note: desLastRow is a range indicates the last row having contents. desSheet is a worksheet.
Best regards,
lolo^^
desLastRow.Row <> desSheet.Cells(desSheet.Rows.count, "F").End(xlUp).Row
Public desLastRow As Range
desLastRow = desSheet.Cells(desSheet.Rows.count, "F").End(xlUp)
this = desLastRow.Row
Can you show us some more code, specifically your Dim statement for the desLastRow variable and the statement where you assign a value to the desLastRow variable (also, some of the code surrounding them might help us also).
desLastRow = desSheet.Cells(desSheet.Rows.count, "F").End(xlUp)
Set desLastRow = desSheet.Cells(desSheet.Rows.count, "F").End(xlUp)
Set des = Application.Workbooks.Open(desPathName, True, False)
On Error GoTo browse
Are you running any On Error Resume Next statements? I ask because this line...
should be raising an error. Since desLastRow is declared as a Range variable, you need to use Set to assign a range to it...Code:desLastRow = desSheet.Cells(desSheet.Rows.count, "F").End(xlUp)
Also, the error message you reported to us indicates that at that point in your code, it does not see desLastRow as a Range object. Perhaps there is a scope issue at work here. What module is the Public declaration of desLastRow in and what module is the error occurring at?Code:Set desLastRow = desSheet.Cells(desSheet.Rows.count, "F").End(xlUp)
The On Error statement should go before the line of code you anticipate might raise an error. Try reversing the two statements you posted.And do you happen to know the following:
How come when there's a error when opening the file, the code does not go to 'browse' to run the code there?Code:Set des = Application.Workbooks.Open(desPathName, True, False) On Error GoTo browse
The On Error statement should go before the line of code you anticipate might raise an error. Try reversing the two statements you posted.