下面我有下面的IF OR
语句,它可以完成我想要的工作,但是如果可以将其创建为用户定义的函数,我希望这样做
基本上,我有2列数据,这些列将永远只有红色琥珀色或绿色作为它们的值,并且我希望UDF能够查看列中的两个单元格并返回最坏情况,例如例如,如果一列为琥珀色而一列为绿色,则UDF将返回琥珀色,因为它比绿色差
=IF(OR(AZ8="Red",AY8="Red"),"Red",IF(OR(AZ8="Amber",AY8="Amber"),"Amber","Green"))
这是我到目前为止所拥有的
Function CalculateOverallRAG(CellRef1 As Range,CellRef2 As Range,RAGStatus As String) As String
If CellRef1 = "Red" Or CellRef2 = "Red" Then
RAGStatus = "Red"
ElseIf CellRef1 = "Amber" Or CellRef2 = "Amber" Then
RAGStatus = "Amber"
Else
RAGStatus = "Green"
End If
CalculateOverallRAG = RAGStatus
End Function