基于if公式的Excel运算符

问题描述 投票:0回答:1

我使用的是Excel 2016。是否可以根据条件来选择运算符?如果一个单元格中包含文本 "绝对",它应该做加法,如果文本是 "百分比",它应该做乘法。

我正试图缩短我的公式。现在我使用的是 "绝对"。=If(A1="Absolute",C1+B1,C1*B1)但我理想中的公式是这样的。= C1 & If(A1="Absolute",+,*) & B1

先谢谢你!

excel excel-formula conditional-statements operators
1个回答
1
投票

我是这样解决的。

Dim FinalPrice As Double

If Add_on = 0 Then
FinalPrice = Price
ElseIf Add_on_Type = "Absolute" Then
FinalRate = Price+ Add_on
ElseIf Add_on_Type = "Percentage" Then
FinalRate = Price* Add_on
Else: MsgBox "Add-on type is neither absolute nor percentage"
End If
CalcAddon = FinalPrice
End Function

我在单元格中的函数现在是这样的: =CalcAddon(C1,A1,B1)

© www.soinside.com 2019 - 2024. All rights reserved.