简体   繁体   English

如果条件不正确,则在单元格中“跳过写入”的 Excel 公式

[英]Excel formula for “skipping to write” in cell if conditions are not correct

So I got stuck with a problem where I could use some feedback.所以我遇到了一个问题,我可以使用一些反馈。 I am looking at cell B1 and C1 if either contains a specific value.如果任一单元格包含特定值,我正在查看单元格 B1 和 C1。 If it does I want to write value from D1 (true or false) to A1.如果是,我想将 D1(真或假)中的值写入 A1。

This is the formula I started with and it's used in A1 (I had to simplify with fruits both due to data protection and simplification): =IF(OR(B1="Apples";C1="Apples");"D1";"")这是我开始使用的公式,它在 A1 中使用(由于数据保护和简化,我不得不用水果进行简化): =IF(OR(B1="Apples";C1="Apples");"D1"; "")

The problem now is that I want to "skip" a write if it doesn't contain any of the values but it won't work since the IF statement is left empty.现在的问题是,如果写入不包含任何值,我想“跳过”写入,但由于 IF 语句为空,因此它将不起作用。 As you can see in the attached picture, I leave an empty space between each "True".正如您在附图中看到的那样,我在每个“真”之间留了一个空白。

I did find a lot of solutions on how to "skip" empty cells, but that's not what I am after here.我确实找到了很多关于如何“跳过”空单元格的解决方案,但这不是我想要的。 Is this even possible with Excel-formulas or do I need to dig into VBA?这甚至可以使用 Excel 公式还是我需要深入研究 VBA?

Result of my formula:我的公式的结果:

我的公式的结果

Expecation:期望:

期待

Does it make sense?是否有意义?

My manager actually solved this for me if anyone is interested.如果有人感兴趣,我的经理实际上为我解决了这个问题。 The use case is a bit weird I can agree on that, but here is solution: Formula required to "scatter the TRUE's用例有点奇怪,我可以同意,但这里是解决方案: “分散 TRUE 的公式”

Formula to get the first TRUE获得第一个 TRUE 的公式

Formula for the upcoming TRUE's即将到来的 TRUE 的公式

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

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