简体   繁体   English

Excel和/或多个IF的问题

[英]Issues with Excel And/OR Multiple IFs

Column F checks my "database"(Sheet1) and tells me if there's a match from current sheet Column G. F列检查我的“数据库”(Sheet1),并告诉我当前工作表G列是否存在匹配项。

=VLOOKUP(ShippingPlanPREP!C2,MainDatabase!A:G,E2,FALSE)

I get a return of either a Price, a Zero or an #N/A error. 我得到了价格,零或#N / A错误的返回。 At the moment I don't care about the price, because it means I have the unit and needed condition in Sheet1 "MainDatabase" . 目前,我不在乎价格,因为这意味着我在Sheet1 "MainDatabase"具有单位和所需的条件。

So I have basically two different directions I'd like to go; 所以我基本上有两个不同的方向要走。

Adding a new Unit (#N/A error) And condition's price 添加新的单位(#N / A错误)和条件的价格

OR 要么

Adding a new Unit Condition price (0 was returned) 添加新的单位条件价格(返回了0)

Here's where my problem is I believe: 我认为这是我的问题所在:

Column I,J and K represent different Conditions/prices and need to tell me, based off Column F, to either look for the already known condition/price in the database, look to see if this item condition is even being updated, or add the price (from Column C) because the needed criteria match. I,J和K列代表不同的条件/价格,因此需要根据F列告诉我,以查找数据库中已知的条件/价格,查看该项目条件是否正在更新,或者添加价格(来自C列),因为所需条件匹配。

Code I've tried: 我尝试过的代码:

=IF(AND(AND($F2=0,(ISNA($F2)),ShippingPlanPREP!$B2="A")),$C2,VLOOKUP($G2,MainDatabase!A:E,3,FALSE))

I tried AND AND with some success. 我尝试了AND AND并取得了一些成功。 I'm getting Database numbers now, But I'm not getting C2's price in "Amazon_A" etc when it needs to be there. 我现在正在获取数据库编号,但是当它需要在“ Amazon_A”中时,我没有得到C2的价格。

=IF(AND(OR($F2=0,(ISNA($F2)),ShippingPlanPREP!$B2="A")),$C2,VLOOKUP($G2,MainDatabase!A:E,3,FALSE))

I don't think OR is the answer because then I ended up with the same Condition Price on all category's/columns. 我认为答案不是OR,因为这样我最终在所有类别的/列上都使用了相同的Condition Price。

I've tried much more variations than this without success. 我尝试了更多的变化,但没有成功。 Please let me know if more info is needed. 请让我知道是否需要更多信息。 Thank you in advance. 先感谢您。

Example

Let see if breaking it down to simpler terms will help with the logic process and getting what you want done. 让我们看看将其分解为更简单的术语是否有助于逻辑过程并完成您想做的事情。

Value of F | Process to follow
------------------------------
#NA        |       A
0          |       B
$42.42     |       C

Going the if route, we would want to use a formula like this: 走if路线,我们想使用这样的公式:

=IF(isNA(F2), "A" , IF(F2=0,"B","C"))

You should be able to toss that into your sheet and test that you are getting your three letters. 您应该能够将其扔到工作表中,并测试您是否收到了三个字母。 When that is working, substitue your equations for what you want to happen in for each of the letters. 在这种情况下,用方程式替换每个字母要发生的变化。 Make sure the individual equations are working first. 确保各个方程首先生效。

So to help clarify your equations lets look at that table again. 因此,为帮助澄清方程式,请再次查看该表。

Value of F | Process to follow
------------------------------
#NA        | "What to do when F is #NA"
0          | $C2,VLOOKUP($G2,MainDatabase!A:E,3,FALSE)
$42.42     | "What to do when F is a price"

That is one formula. 那是一个公式。 If I place it there it means that is the action to take when F is equal to 0. I only saw one formula, so the question now it what formula or action do you want to take for the other two results. 如果将其放在此处,则意味着这是F等于0时要采取的动作。我只看到一个公式,所以现在的问题是,您希望对其他两个结果采取什么公式或动作。 Now I may have substituted your formula in for the wrong F value, but you can adjust that to suit your needs. 现在,我可能已经用您的公式替换了错误的F值,但是您可以根据需要进行调整。 If I were to substitute your formula into the previous if statement it would look something like this: 如果我将您的公式替换为前面的if语句,它将看起来像这样:

=IF(isNA(F2),"What to do when F is #NA",IF(F2=0,$C2,VLOOKUP($G2,MainDatabase!A:E,3,FALSE),"What to do when F is a price"))

Supplemental Information 补充资料

If the logic table above is over simplified and you have other conditions that must be true before and action is taken, you can add columns before the action is taken column to build up your thought process. 如果上面的逻辑表过于简化,并且您在采取行动之前还必须满足其他条件,则可以在采取行动之前添加列,以建立您的思考过程。 IF that is the case, update your question with your logic table, and we can help you out with building IF statements with AND and OR as needed. 如果是这种情况,请使用逻辑表更新您的问题,我们可以根据需要使用AND和OR构建IF语句来帮助您。 The main thing when building your table to help keep things clearer for you is to treat each row as unique in terms of what much be true in order for your process to happen. 建立表以帮助您使事情更清楚时,主要的事情是将每一行都视为唯一行,以确保过程能够正确执行。

Example

Value of F | Value of another cell | Process to follow
------------------------------------------------------
#NA        |  True                 |     A
0          |  True                 |     B
$42.42     |  True                 |     C
#NA        |  False                |     A
0          |  False                |     C
$42.42     |  False                |     B

This is just one of many approaches. 这只是许多方法之一。

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

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