G
GB
I have a very large and complex spreadsheet - 6MB on the disk, about 20
worksheets, user-defined functions. It all calculates correctly, without any
obvious error values. However, if I copy a worksheet into another completely
new workbook (copying the values only, not the formulae), all the
user-defined values in my spreadsheet show a #VALUE! error. Those errors go
away again as soon as I press the F9 key.
One of the possible causes that occurs to me is that the user-defined
functions are not self-contained. For example, one of the functions will use
data from another part of the spreadsheet. It occurs to me that when the
focus is moved to a completely new spreadsheet VBA may be getting confused
and trying to find that data on the new spreadsheet. A quick test shows that
the problem does not occur if I add the worksheet with the data the function
needs into the new workbook. So, I think that must be it.
So, the problem comes down to this:
How do I persuade the VBA function to look for its data on its own 'parent'
spreadsheet, rather than on the spreadsheet that just happens to have the
focus at the moment? (Can't just use the parent spreadsheet name, as that
changes when I produce a new version.)
Tearing my hair out over this, so any input would be very welcome.
worksheets, user-defined functions. It all calculates correctly, without any
obvious error values. However, if I copy a worksheet into another completely
new workbook (copying the values only, not the formulae), all the
user-defined values in my spreadsheet show a #VALUE! error. Those errors go
away again as soon as I press the F9 key.
One of the possible causes that occurs to me is that the user-defined
functions are not self-contained. For example, one of the functions will use
data from another part of the spreadsheet. It occurs to me that when the
focus is moved to a completely new spreadsheet VBA may be getting confused
and trying to find that data on the new spreadsheet. A quick test shows that
the problem does not occur if I add the worksheet with the data the function
needs into the new workbook. So, I think that must be it.
So, the problem comes down to this:
How do I persuade the VBA function to look for its data on its own 'parent'
spreadsheet, rather than on the spreadsheet that just happens to have the
focus at the moment? (Can't just use the parent spreadsheet name, as that
changes when I produce a new version.)
Tearing my hair out over this, so any input would be very welcome.