Would someone please explain why I get the error. in Excel 2013
Run-time error '1004':
Application-defined or object defined error
Senario (Description followed by code)
I have opened a workbook and worksheet (wsBS) from within the main worksheet (wsData).
I want to find the last row of the main worksheet and the last row of the opened worksheet.
LastRow and lastRowBS are defined as Integers
The following code works for the main worksheet (wsData)
The following code for the opened worksheet fails
However the following code for the opened worksheet works (workaround)
can anyone please explain why?
Thank you
Run-time error '1004':
Application-defined or object defined error
Senario (Description followed by code)
I have opened a workbook and worksheet (wsBS) from within the main worksheet (wsData).
I want to find the last row of the main worksheet and the last row of the opened worksheet.
LastRow and lastRowBS are defined as Integers
The following code works for the main worksheet (wsData)
Code:
LastRow = wsData.Cells(Rows.Count, 1).End(xlUp).Row
The following code for the opened worksheet fails
Code:
lastRowBS = wsBS.Cells(Rows.Count, 1).End(xlUp).Row
However the following code for the opened worksheet works (workaround)
Code:
lastRowBS = wsBS.Range("A65536").End(xlUp).Row
can anyone please explain why?
Thank you
Last edited by a moderator: