I'm getting the Runtime Error 1004 Application Defined or object defined error but not seeing what is causing the error!
Dim ExcelFile As Workbook
Dim CRrow As Long
Dim PRrow As Long
Set ExcelFile = ActiveWorkbook
---> I do some code where I open another workbook and copy data across to ExcelFile and then close the other workbook (this is all working as expected)
CRrow = 2
Do Until IsEmpty(ExcelFile.Sheets("CurrentReport").Range(CRrow, 2)) -----> This is where I'm getting the error but I can't workout what isn't defined
PRrow = 2
Do Until IsEmpty(ExcelFile.Sheets("PreviousReport").Range(PRrow, 1))
If ExcelFile.Sheets("CurrentReport").Range(CRrow, 2) = ExcelFile.Sheets("PreviousReport").Range(PRrow, 1) Then
---> Do some checks
Else
PRrow = PRrow + 1
End If
Loop
CRrow = CRrow + 1
Loop
I'm basically trying to go through one list of data and then compare it to another list of data and when I find the matching ID's do some checks to see if some specific fields have changed and then return a value but it doesn't seem to be picking up the first ID I want to check so I have a feeling my other references later in the code will also have the same issue. I feel like it's related to the ExcelFile variable but not sure what is wrong with it.
Dim ExcelFile As Workbook
Dim CRrow As Long
Dim PRrow As Long
Set ExcelFile = ActiveWorkbook
---> I do some code where I open another workbook and copy data across to ExcelFile and then close the other workbook (this is all working as expected)
CRrow = 2
Do Until IsEmpty(ExcelFile.Sheets("CurrentReport").Range(CRrow, 2)) -----> This is where I'm getting the error but I can't workout what isn't defined
PRrow = 2
Do Until IsEmpty(ExcelFile.Sheets("PreviousReport").Range(PRrow, 1))
If ExcelFile.Sheets("CurrentReport").Range(CRrow, 2) = ExcelFile.Sheets("PreviousReport").Range(PRrow, 1) Then
---> Do some checks
Else
PRrow = PRrow + 1
End If
Loop
CRrow = CRrow + 1
Loop
I'm basically trying to go through one list of data and then compare it to another list of data and when I find the matching ID's do some checks to see if some specific fields have changed and then return a value but it doesn't seem to be picking up the first ID I want to check so I have a feeling my other references later in the code will also have the same issue. I feel like it's related to the ExcelFile variable but not sure what is wrong with it.