|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 100026815 于 2015-12-30 00:08 编辑
求老师帮助:我想实现读取C2数值进行比较,将结果自动填至D2内,如下编写能实现吗?谢谢。急急急急.......
Function tuokou(dianliu As Double, t As Integer)
Dim dianliu, t
dianliu = Range("C2")
t = Range("D2")
If dianliu = "" Then
t = ""
Else
If dianliu <= 6 / 1.2 Or dianliu > 1250 / 1.2 Then
t = "超限"
Else
If dianliu > 6 / 1.2 And dianliu <= 10 / 1.2 Then
t = 10
Else
If dianliu > 10 / 1.2 And dianliu <= 16 / 1.2 Then
t = 16
Else
If dianliu > 16 / 1.2 And dianliu <= 20 / 1.2 Then
t = 20
Else
If dianliu > 20 / 1.2 And dianliu <= 25 / 1.2 Then
t = 25
Else
If dianliu > 25 / 1.2 And dianliu <= 30 / 1.2 Then
t = 30
Else
If dianliu > 30 / 1.2 And dianliu <= 32 / 1.2 Then
t = 32
Else
If dianliu > 32 / 1.2 And dianliu <= 40 / 1.2 Then
t = 40
Else
If dianliu > 40 / 1.2 And dianliu <= 50 / 1.2 Then
t = 50
Else
If dianliu > 50 / 1.2 And dianliu <= 63 / 1.2 Then
t = 63
Else
If dianliu > 63 / 1.2 And dianliu <= 80 / 1.2 Then
t = 80
Else
If dianliu > 80 / 1.2 And dianliu <= 100 / 1.2 Then
t = 100
Else
If dianliu > 100 / 1.2 And dianliu <= 125 / 1.2 Then
t = 125
Else
If dianliu > 125 / 1.2 And dianliu <= 160 / 1.2 Then
t = 160
Else
If dianliu > 160 / 1.2 And dianliu <= 180 / 1.2 Then
t = 180
Else
If dianliu > 180 / 1.2 And dianliu <= 200 / 1.2 Then
t = 200
Else
If dianliu > 200 / 1.2 And dianliu <= 225 / 1.2 Then
t = 225
Else
If dianliu > 225 / 1.2 And dianliu <= 250 / 1.2 Then
t = 250
Else
If dianliu > 250 / 1.2 And dianliu <= 315 / 1.2 Then
t = 315
Else
If dianliu > 315 / 1.2 And dianliu <= 350 / 1.2 Then
t = 350
Else
If dianliu > 350 / 1.2 And dianliu <= 400 / 1.2 Then
t = 400
Else
If dianliu > 400 / 1.2 And dianliu <= 500 / 1.2 Then
t = 500
Else
If dianliu > 500 / 1.2 And dianliu <= 600 / 1.2 Then
t = 600
Else
If dianliu > 600 / 1.2 And dianliu <= 700 / 1.2 Then
t = 700
Else
If dianliu > 700 / 1.2 And dianliu <= 800 / 1.2 Then
t = 800
Else
If dianliu > 800 / 1.2 And dianliu <= 1000 / 1.2 Then
t = 1000
Else
If dianliu > 1000 / 1.2 And dianliu <= 1250 / 1.2 Then
t = 1250
Else
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
Range("D2").Value = t
End Sub
|
|