我正在尝试在具有多个条件的状态情况下运行宏,我知道我们很乐意使用“”分隔多个条件,但是我们可以用什么来分隔必须同时满足的条件?
这是代码
Select Case Cells(i, 248)
Case "B": Fees_Jan = (Cells(i, 267).Value - Cells(i, 265)) / 2
Case "C": Fees_Jan = (Cells(i, 267).Value - Cells(i, 265)) * 0.25
Case "A", Cells(i, 250) = "BANANAS", Cells(i, 236) = "MAÇAS": Fees_Jan = (Cells(i, 267).Value * 0.35 / 1 / 2)
Case "A", Cells(i, 250) = "PERAS", Cells(i, 236) = "MORANGOS": Fees_Jan = ((Cells(i, 262).Value) * 0.2 / 2) + (Cells(i, 263).Value - (Cells(i, 265).Value) / 3)
Case Else: Fees_Jan = Cells(i, 265).Value / 2
End Select
如果我仅隔离并运行最后一个Case“ A”,则可以正常运行,但是我运行的所有代码都运行良好。.有人可以帮助吗?
答案 0 :(得分:1)
您可以评估Select for True。
Select Case True
Case Cells(i, 248) = "B"
Fees_Jan = (Cells(i, 267).Value - Cells(i, 265)) / 2
Case Cells(i, 248) = "C"
Fees_Jan = (Cells(i, 267).Value - Cells(i, 265)) * 0.25
Case Cells(i, 248) = "A" And Cells(i, 250) = "BANANAS" And Cells(i, 236) = "WILLHILL_CLEVERADV_HYBRID"
Fees_Jan = (Cells(i, 267).Value * 0.35 / 1 / 2)
Case Cells(i, 248) = "A" And Cells(i, 250) = "PERAS" And Cells(i, 236) = "MORANGOS"
Fees_Jan = ((Cells(i, 262).Value) * 0.2 / 2) + (Cells(i, 263).Value - (Cells(i, 265).Value) / 3)
Case Else
Fees_Jan = Cells(i, 265).Value / 2
End Select