Hi there,
Well I think the main problem is the line:
This can be VERY dangerous if you don't fully realise what you're doing! Basically it tells Excel to ignore any errors it encounters and to just carry on regardless. I'm fairly certain that the workbook you selected for opening doesn't HAVE a worksheet with the tabname "Sheet5", so when Excel executes the line
it can't find the worksheet (and therefore can't activate it) but because of the "On Error Resume Next" command it happily copies and pastes the data from whatever worksheet happens to be already active in the active workbook (i.e. whatever worksheet was active when the workbook was last saved).
As far as I can tell, the "On Error Resume Next" isn't actually needed in your code, so delete it, run the code again and see if the "ActiveWorkbook.Worksheets("Sheet5").Activate" line generates a "Subscript out of range" error - this will happen if the opened workbook doesn't contain a worksheet with the tabname "Sheet5".
Hope this helps - please let me know how you get on.
Regards,
Greg M
Bookmarks