Yeah, I know there are some other topics related to that, but I thought it would be better if I create another one, since this is kind of different. Anyway, if someone belie
You are using workbookA so set sheetB.
Set varSheetB = wbkA.Worksheets("Balance sheet") ' or whatever sheet you need
should be:
Set varSheetB = wbkB.Worksheets("Balance sheet") ' or whatever sheet you need
Sorry I missed this the first time around:
varSheetA = Worksheets("Balance Sheet").Range(strRangeToCheck)
varSheetB = Worksheets("Balance Sheet").Range(strRangeToCheck)
should be:
varSheetA = varSheetA.Range(strRangeToCheck)
varSheetB = varSheetB.Range(strRangeToCheck)
Direct calls of the Worksheets function will always refer to the ActiveWorkbook. Instead always call it from the relevant object (wkbA.Worksheets("...") or wkbB.Worksheets("..."))
Btw. you can also combine both assignments into one:
strRangeToCheck = "B6:D49"
Set wbkA = Workbooks.Open(Filename:="C:\Users\Desktop\BalanceSheet.xls")
Set varSheetA = wbkA.Worksheets("Balance sheet").Range(strRangeToCheck)
Set wbkB = Workbooks.Open(Filename:="C:\Users\Desktop\BalanceSheet_old.xls")
Set varSheetB = wbkB.Worksheets("Balance sheet").Range(strRangeToCheck)