简体   繁体   English

如果VLOOKUP错误返回,如何保留以前的Excel单元格值

[英]How to keep previous excel cell value if VLOOKUP return with error

Reference Sheet: https://docs.google.com/spreadsheets/d/1UQVeVLLuZbre_RL0H68K1yQ_3ybY3mRIBYPJUfmf1k0/edit?usp=sharing 参考表: https : //docs.google.com/spreadsheets/d/1UQVeVLLuZbre_RL0H68K1yQ_3ybY3mRIBYPJUfmf1k0/edit?usp=sharing

In above reference sheet, under row, if I change the "alpha", into "beta" the corresponding value will return error #N/A since the formula is not able to find the name reference. 在上面的参考表中的行下,如果我将“ alpha”更改为“ beta”,则相应的值将返回错误#N / A,因为该公式无法找到名称参考。 But I am trying to keep the previous value, instead of showing #N/A. 但是我试图保留以前的值,而不是显示#N / A。

Eg: currently formula looking for alpha and corresponding value is 10, so the VLOOKUP fill value field with 10. If I change alpha into beta in "Row", the previous populated value corresponding to alpha, ie 10, will change to #N/A since vlookup not able to find the name which is looking for. 例如:当前要查找alpha的公式,其对应值为10,因此VLOOKUP填充值字段为10。如果我将“ Row”中的alpha更改为beta,则对应于alpha的先前填充值(即10)将更改为#N /从vlookup开始,无法找到要查找的名称。 but I need to keep the previous value 10 there instead #N/A eventhough vlookup not able to find that. 但是我需要将先前的值保持在10而不是#N / A,尽管vlookup无法找到该值。

A formula will always evaluate the current values of precedents and there is no way to conditionally revert to the previous values of these precedents. 公式将始终评估先例的当前值,并且无法有条件地还原为这些先例的先前值。

What you describe can be achieved with macros, where the VBA can be used to store previous values in backup scenarios. 您所描述的内容可以通过宏来实现,其中VBA可用于在备份方案中存储以前的值。 Such a scenario might be doable for a few cells but is impractical for a large data set. 这种情况对于少数几个单元可能可行,但对于大型数据集则不可行。

You may want to re-think your data architecture. 您可能需要重新考虑您的数据架构。 There may be other approaches than the one you are asking for. 除了您要的方法以外,可能还有其他方法。

Actually, I was able to do this using a formula. 实际上,我能够使用公式来做到这一点。

=IFNA(VLOOKUP(value, table, col_index, [range_lookup]),current_cell) = IFNA(VLOOKUP(值,表,col_index,[range_lookup]),current_cell)

current_cell will be the cell you are placing your formula on. current_cell将是您要在其上放置公式的单元格。 The caveat in using this is that you will be creating a circular reference which might cause some of your calculations not work properly. 使用此方法的警告是,您将创建一个循环引用,这可能会导致某些计算无法正常工作。 But enabling iterations can be a work around for this. 但是启用迭代可以解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM