IIF函数判断
Sub 判断4()
Range("a3") = IIf(Range("a1") <= 0, "负数或零", "负数")
End Sub
Sub 判断1() '单条件判断 If Range("a1").Value > 0 Then Range("b1") = "正数" Else Range("b1") = "负数或0" End If End Sub Sub 判断2() '多条件判断 If Range("a1").Value > 0 Then Range("b1") = "正数" ElseIf Range("a1") = 0 Then Range("b1") = "等于0" ElseIf Range("B1") <= 0 Then Range("b1") = "负数" End If End Sub Sub 多条件判断2() If Range("a1") <> "" And Range("a2") <> "" Then Range("a3") = Range("a1") * Range("a2") End If End Sub |
select判断 Sub 判断1() '单条件判断 |
Sub if区间判断() If Range("a2") <= 1000 Then Range("b2") = 0.01 ElseIf Range("a2") <= 3000 Then Range("b2") = 0.03 ElseIf Range("a2") > 3000 Then Range("b2") = 0.05 End If End Sub |
Sub select区间判断() Select Case Range("a2").Value Case 0 To 1000 Range("b2") = 0.01 Case 1001 To 3000 Range("b2") = 0.03 Case Is > 3000 Range("b2") = 0.05 End Select End Sub |