|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 右()
Cells(1, 1) = "北京地铁十四号线08合同段"
Dim l, B#, I%
I = 4
Do
l = Cells(I, 1)
If Cells(I, 1) = "" Then MsgBox "请输入数据"
If 17371.6 <= l And l <= 17500.85 Then
B = 20.311 + (l - 17371.6) * 2 / 1000
ElseIf 17500.85 < l And l <= 17518 Then
B = 20.57 + (l - 17500.85) * 2 / 1000 + (l - 17500.85) ^ 2 / (2 * 5000)
ElseIf 17518 < l And l <= 17535.15 Then
B = 20.756 + (l - 17535.15) * 8.86 / 1000 + (l - 17535.15) ^ 2 / (2 * 5000)
ElseIf 17535.15 < l And l <= 17700 Then
B = 20.756 + (l - 17535.15) * 8.86 / 1000
ElseIf 17700 < l And l <= 17707.98 Then
B = 22.217 + (l - 17700) * 8.86 / 1000 - (l - 17700) ^ 2 / (2 * 5000)
ElseIf 17707.98 < l And l <= 17714.68 Then
B = 22.329 + (l - 17714.68) * 6.18 / 1000 - (l - 17714.68) ^ 2 / (2 * 5000)
ElseIf 17714.68 < l And l <= 17817.85 Then
B = 22.329 + (l - 17714.68) * 6.18 / 1000
ElseIf 17817.85 < l And l <= 17878.3 Then
B = 22.966 + (l - 17817.85) * 6.18 / 1000 - (l - 17817.85) ^ 2 / (2 * 5000)
ElseIf 17878.3 < l And l <= 17938.75 Then
B = 22.252 - (l - 17938.75) * 18 / 1000 - (l - 17938.75) ^ 2 / (2 * 5000)
ElseIf 17938.75 < l And l <= 17988.953 Then
B = 22.252 - (l - 17938.75) * 18 / 1000
Else
MsgBox "超出里程范围"
Exit Do
End If
Cells(I, 2) = B
I = I + 1
Loop Until Cells(I, 1) = ""
End Sub
|
|