问题
We work with Vlookup functions all of he time at my job. Specifically, we use Vlookup functions that reference tables on seperate sheets. There is a very odd occurance with these functions. It seems as if certain functions require the Vlookup table sheet to be open, and will return a #VALUE error if the sheet is not open. Other functions return a correct result with the Vlookup table sheet not open. Can someone give me an explanation by chance?
Here is an example of a nested If/Vlookup that will NOT run unless the Vlookup table sheet known as Sales Page Territories is open:
=IF(1>COUNTIF('[Salespage Territories.xlsx]IODC Zip'!$C:$C,$X3),VLOOKUP($X3,'[Salespage Territories.xlsx]IODC State'!$A:$B,2,FALSE),VLOOKUP($X3,'[Salespage Territories.xlsx]IODC Zip'!$A:$D,4,TRUE))
回答1:
VLOOKUP
works OK on closed workbooks unless you have lookup values with more than 255 characters or if return values go above that same limit
The problem with the formula you quote is not with VLOOKUP
but COUNTIF
- COUNTIF
doesn't work on closed workbooks - see here. I'm not quite sure why you are checking for X3 in column C but you could use MATCH instead, i.e.
=IF(ISNA(MATCH($X3,'[Salespage Territories.xlsx]IODC Zip'!$C:$C,0)),VLOOKUP($X3,'[Salespage Territories.xlsx]IODC State'!$A:$B,2,FALSE),VLOOKUP($X3,'[Salespage Territories.xlsx]IODC Zip'!$A:$D,4,TRUE))
MATCH will work with closed workbooks
回答2:
See here for a description of the various aspects of external links.
According to my experience, external references always must be open for formulas to display correct results ... otherwise you get #N/A
Excel opens referenced workbooks
- implicitely because of default settings or
- explicitely because you allow it to do so via the alert bar, the popup dialog or "Data / Edit Links / Open Source")
Workbooks opened this way (see "Data / Edit Links / Check Status" --> status="OK") still are not visible ... they exist only as workbook objects ... so you might think they aren't open.
If you have a referenced workbook open and close it before you close the workbook referencing (making use of) it, it will remain open in the background for being referenced, allthough it is not displayed anymore.
There's of course also a dependency on the calculation settings of the workbook.
来源:https://stackoverflow.com/questions/19635020/why-do-some-excel-documents-have-to-be-open-for-a-vlookup-and-not-others