手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

EXCEL VBA中 if条件语句的介绍

时间:2024-10-16 03:16:25

1、'单行写法 (后面将省去首尾两句)Sub 条件语句()If a < 20 Then [b2] = "good"end sub

2、'多行写法If a < 20 Then[b2] = "shit"End If'if esleIf a < 20 Then[b2] = "yes"Else[b2] = "no"End If

3、'多条件判断If a < 20 Then[b2] = "挢旗扦渌;very bad"ElseIf a < 40 Then[b2] = "bad"ElseIf a < 60 Then[b2] = "normal"Else[b2] = "good"End If

4、单行写法if后,执行多条语句,用冒号隔开If a < 20 Then [b2] = "good": [b3] = "yes"'单行if elseIf a < 20 Then [b2] = "aa" Else [b2] = "bb"

5、总结:if 条件1 then 条件1成立时运行的语句elseif 条件2 then条件2成立运行的语句....else 所有条件都不成立时运行的语句end if

© 手抄报圈