Hi, I am trying to collate a number of different spreadsheets using VBA to achieve a complicated layout.
The following code exert should find a string within a calculated range:
however it fails whenever the workbook identified by 'wbFMPPrevious' isn't active. To show you how I've come to this conclusion:
This code (a simplified version of the previous example):
returns '$A$5:$A$14' which it should, but only when the last sheet I looked at was 'FMP 18-03.xls' as returned by wbFMPPrevious.name. If I look at another sheet or even simply run the process from the parent sheet, which is what I need to do, then it fails with a Run-time error '1004': Application defined or object defined error'.
I don't mind if I've made a mistake, but this apparent inconsistent behaviour is driving me insane!
Please help.
Have a good Christmas and a great New Year.
Regards
The following code exert should find a string within a calculated range:
Code:
sDate2 = wbFMPPrevious.Worksheets(wsDestination.Name).Range(Cells(nPrevAvail + 2, 1), Cells(nPrevAvail + 11, 1)).Find("MD", lookat:=xlPart)
however it fails whenever the workbook identified by 'wbFMPPrevious' isn't active. To show you how I've come to this conclusion:
This code (a simplified version of the previous example):
Code:
wbFMPPrevious.Worksheets(wsDestination.Name).Range(Cells(5, 1), Cells(14, 1)).address
returns '$A$5:$A$14' which it should, but only when the last sheet I looked at was 'FMP 18-03.xls' as returned by wbFMPPrevious.name. If I look at another sheet or even simply run the process from the parent sheet, which is what I need to do, then it fails with a Run-time error '1004': Application defined or object defined error'.
I don't mind if I've made a mistake, but this apparent inconsistent behaviour is driving me insane!
Please help.
Have a good Christmas and a great New Year.
Regards