这不需要什么VB程序啊,一个简单的Excel公式就行了
设行李重量在A列,收费在B列,则B1单元格的公式为
=IF(A1<=50, A1*0.02, 50*0.02+(A1-50)*0.05)
计算所得结果即为应付的行李费
VB程序也很简单,几句话就完了,如下:
Sub packgecost()
Dim weight As Variant
Dim cost As Variant
weight = Cells(1, 1)
If weight <= 50 Then
cost = weight * 0.02
Else
cost = 50 * 0.02 + (weight - 50) * 0.05
End If
Cells(1, 2) = cost
End Sub