|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
在下很菜。做了个表格,大致就是输入商品的销售金额能除尽单价的(就是没有余数的),好判断是哪种价格的商品,然后统计数量和价格构成。由于商品价格都是有小数的,有的能除尽,有的就显示错误,比如说单价为7.86和2.86的,输入78.6我28.6就显示结果错误,试了好几种函数如MOD、INT、FIX等,可结果都是错误,请大家帮我看下,指出我的错误,十分感谢。附件和代码如下:
Sub zc()
Dim i As Integer
For i = 2 To 301
If Cells(i, 1) / 2.84 = Int(Cells(i, 1) / 2.84) Then
Cells(i, 2) = Cells(i, 1) / 2.84
Cells(i, 3) = Cells(i, 2) * 1.81
Cells(i, 4) = Cells(i, 2) * 0.95
Cells(i, 5) = Cells(i, 2) * 0.08
ElseIf Cells(i, 1) / 2.86 = Int(Cells(i, 1) / 2.86) Then
Cells(i, 2) = Cells(i, 1) / 2.86
Cells(i, 3) = Cells(i, 2) * 1.81
Cells(i, 4) = Cells(i, 2) * 0.95
Cells(i, 5) = Cells(i, 2) * 0.1
ElseIf Cells(i, 1) / 7.86 = Int(Cells(i, 1) / 7.86) Then
Cells(i, 2) = Cells(i, 1) / 7.86
Cells(i, 3) = Cells(i, 2) * 3.96
Cells(i, 4) = Cells(i, 2) * 1.4
Cells(i, 5) = Cells(i, 2) * 2.5
ElseIf Cells(i, 1) / 13.86 = Int(Cells(i, 1) / 13.86) Then
Cells(i, 2) = Cells(i, 1) / 13.86
Cells(i, 3) = Cells(i, 2) * 9.96
Cells(i, 4) = Cells(i, 2) * 1.4
Cells(i, 5) = Cells(i, 2) * 2.5
ElseIf Cells(i, 1) / 20.86 = Int(Cells(i, 1) / 20.86) Then
Cells(i, 2) = Cells(i, 1) / 20.86
Cells(i, 3) = Cells(i, 2) * 9.96
Cells(i, 4) = Cells(i, 2) * 1.4
Cells(i, 5) = Cells(i, 2) * 9.5
Else
Cells(i, 2) = "错误"
End If
Next
End Sub
|
|