"Subscript out of range" also occurs when the name of the workbook (possibly Sheetname too) does not exist.
Check the value of the variable MasterFile, make sure it is correct.