I have some code that puts a formula into a worksheet that can reference another worksheet that may not exist until the user elects to have the additional worksheets.
An example of a worksheet formula created by code is below. It goes in cell C133 in a worksheet called ‘Certificate’.
ActiveCell.FormulaR1C1 = _
“=IF(Details!R9C2<2,"""",IF('Results Sheet (2)'!R41C6=""NO"",'Results Sheet (2)'!R44C5=""ERROR"","""",'Work Sheet (2)'!R11C3))"
Note the worksheet names (eg Results Sheet (2)) as these cannot be AutoFilled to subsequent cells. Therefore, the problem I face is that each line of code has to be manually edited for each formula. This is because of the references to worksheets that may not exist. (Users can not simply cancel the Update Links dialog because other cells need to be updated automatically.)
What I would like is a pointer to how to write the code so that code for sheets that might not yet exist could be created with a Loop type of operation although I haven't been able to come up with anything yet.
At present, I would have up to 50 lines of referencing formulae (and either 3 or 4 columns on 2-3 worksheets in up to 30 workbooks.) Quite a lot of manually edited code!
Any suggestions? TIA