工具 -> 宏 -> Visual basic 编辑器 -> 插入一个模块 -> 添加下列代码
ruby 代码
- Function cal_tax(v) As Double
- Dim result As Double
- Select Case v
- Case Is <= 500
- result = v * 0.1 - 25
- Case Is <= 1600
- result = v * 0.1 - 25
- Case Is <= 2000
- result = (v - 1600) * 0.1 - 25
- Case Is <= 5000
- result = (v - 1600) * 0.15 - 125
- Case Is <= 20000
- result = (v - 1600) * 0.2 - 375
- Case Is <= 40000
- result = (v - 1600) * 0.25 - 1375
- Case Is <= 60000
- result = (v - 1600) * 0.3 - 3375
- Case Is <= 80000
- result = (v - 1600) * 0.35 - 6375
- Case Is <= 100000
- result = v * 0.1 - 25
- Case Is > 100000
- result = (v - 1600) * 0.45 - 15375
- End Select
- cal_tax = result
- End Function
另存为一个 "加载宏格式 .xla".
工具 -> 加载宏 -> 浏览 -> 选择这个文件就行了