excel 加入swich功能。

excel 加入swich功能。

按ALT+F11调出VBA窗口,插入一个用户模块


excel 加入swich功能。_第1张图片



excel 加入swich功能。_第2张图片


新建模块 把下面代码 复制里面

Function Switch2(Test1 As String, Result1 As String, _
Optional Test2 As String, Optional Result2 As String, _
Optional Test3 As String, Optional Result3 As String, _
Optional Test4 As String, Optional Result4 As String, _
Optional Test5 As String, Optional Result5 As String, _
Optional Test6 As String, Optional Result6 As String, _
Optional Test7 As String, Optional Result7 As String, _
Optional Test8 As String, Optional Result8 As String, _
Optional Test9 As String, Optional Result9 As String, _
Optional Test10 As String, Optional Result10 As String, _
Optional Test11 As String, Optional Result11 As String, _
Optional Test12 As String, Optional Result12 As String, _
Optional Test13 As String, Optional Result13 As String, _
Optional Test14 As String, Optional Result14 As String)

Switch2 = Switch(Test1, Result1, _
Test2, Result2, _
Test3, Result3, _
Test4, Result4, _
Test5, Result5, _
Test6, Result6, _
Test7, Result7, _
Test8, Result8, _
Test9, Result9, _
Test10, Result10, _
Test11, Result11, _
Test12, Result12, _
Test13, Result13, _
Test14, Result14)
End Function


就可以让EXCEL 实现swtich 语句 例:=Switch2(BX4=251,"D",BX4=252,"C",TRUE,"A")

posted on 2017-01-13 16:21 lbsjs 阅读(...) 评论(...) 编辑 收藏

你可能感兴趣的:(excel 加入swich功能。)