I have faced a strange thing in Excel VBA coding.
I have a sheet full of formulas, each refers to the cells in other sheets.
This is a sample formula in cell
Thank you Vityata for your nice explanations, which led me to the answer!
The problem is, the macro was "First" replacing the name in formulas (i.e to test) and THEN creating the new tab "test".
For example, if you set this formula in sheet1, cell A1:
=test2!A1
(Note that you have not created the test2 sheet, yet)
So you obviously get #REF! error.
However, if you THEN create test2 tab (by macro or hand), and come back and check cell A1 formula in sheet1, (also refresh by saving the file), it STILL shows #REF! error, even now test2 tab is really there! (You need to Double click on the cell, and press enter, for that to UPDATE)
As a result, I changed my macro so that it FIRST creates the test tab, and THEN manipulate those formulas.