本文介绍了Excel中的逻辑公式 - 需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个excel公式的帮助。我试图实现以下行为:




  • 公式在单元格A

  • B我们可以有3个可能的值 - 低,中或高



所以如果单元格B的值等于低,那么在A单元格的值为是
如果单元格B中的值等于中等或高,则公式应检查单元格C是否填充且其内容不同,然后请填写或将其留空 。如果为真,则单元格A为是,否则为否。



如果单元格B的值为空,则单元格A为否

解决方案

对于公式,我不是很好,但是这样做会使$ /

  = IF(LEN(B1)大于0,IF(B1 = 低, 是,IF(B1 = 介质,IF(C1<>中请填写,IF(C1是否),否),IF(B1 =高,IF(B1请填写,IF (C1)> 0,是,否),否),否))),否)

如果你想要一个VBA功能(但需要你分别在每个单元格中输入公式,然后将它粘贴到一个模块中,然后在A列中使用它

 函数CheckIt()As String 
Dim r As Long
r = ActiveCell.Row
如果Range(B& r)=low然后
CheckIt =Yes
Else
If(Range(B& r)=medium或Range(B& r) =high)然后
如果((范围(C& r)请填写)和(不是我sEmpty(Range(C& r))))然后
CheckIt =Yes
Else
CheckIt =No
End If
Else
CheckIt =No
如果
结束If
结束函数

示例




I need help with an excel formula. I am trying to achieve the following behaviour:

  • the formula is in cell A
  • in cell B we can have 3 possible values - Low, Medium or High

So if value of cell B is equal to Low then in the A cell the value is "Yes"If the value in cell B is equal to Medium or High then the formula should check if cell C is populated and its content is different then "please fill in" or it is left "blank". If true then cell A is "Yes", if not, then it is "No".

If value of cell B is blank then the cell A is "No" as well.

解决方案

Im not great with formulas but this would do

=IF(LEN(B1)>0,IF(B1="low","Yes",IF(B1="medium",IF(C1<>"please fill in",IF(C1<>"","Yes","No"),"No"),IF(B1="high",IF(B1<>"please fill in",IF(LEN(C1)>0,"Yes","No"),"No"),"No"))),"No")

if you want a VBA function ( but requires you to enter the formula in each cell separately then stick this in a module and then use it in column A

Function CheckIt() As String
    Dim r As Long
    r = ActiveCell.Row
    If Range("B" & r) = "low" Then
        CheckIt = "Yes"
    Else
        If (Range("B" & r) = "medium" Or Range("B" & r) = "high") Then
            If ((Range("C" & r) <> "please fill in") And (Not IsEmpty(Range("C" & r)))) Then
                CheckIt = "Yes"
            Else
                CheckIt = "No"
            End If
        Else
            CheckIt = "No"
        End If
    End If
End Function

Example

这篇关于Excel中的逻辑公式 - 需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 16:28