Office中国论坛/Access中国论坛
标题:
[求助]这段代码如何自定义为函数?
[打印本页]
作者:
linjiandan
时间:
2005-6-21 19:17
标题:
[求助]这段代码如何自定义为函数?
Select Case Range("a1").Value
Case "一月"
Range("d1") = b1 - c1
Case "二月"
Range("d1") = b1 + c1
Case "三月"
Range("d1") = b1 * c1
Case "四月"
Range("d1") = b1 / c1
End Select
作者:
晓月清风
时间:
2005-6-21 21:49
Function selcase(VA1)
'其中VA1可以是引用单元格,也可以是字符串值,如“二月”
Application.Volatile
Select Case VA1
Case "一月"
selcase = [b1] - [c1]
Case "二月"
selcase = [b1] + [c1]
Case "三月"
selcase = [b1] * [c1]
Case "四月"
selcase = [b1] / [c1]
Case Else
selcase = Evaluate("Na()")
'如果VA1的值不在CASE中,则返回错误:#N/A
End Select
End Function
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3