that code works great if i run it on the current worksheet but i'm running it from a different excel file. What i am trying to accomplish is to copy a range of cells from a closed file into the current worksheet. All my variables are correct because i've debug.printed them. its only the line:
first_range = Workbooks("FileNamesList(i)").ActivateRange(TOTAL_SUPPLIER_CHARGE).Address
that gives me a run-time error 9. Subscripts out of range.
TOTAL_SUPPLIER_CHARGE refers to cell C34 and TOTAL_PROFIT refers to cell E34.
these cell values may change if the user inserts a new line therefore the name lists have to be used.
the variable FileNamesList(i) prints the correct file name ie: test1.xls
first_range and second_range are strings
Bookmarks