VBA怎么比较3个单元格数值的大小.如果,最大返回2,最小返回0,中间返回1,返回值在别的单元格中输出 10
要比较的输入单元格B9,C9,D9。对应输出的单元格E9,F9,G9,单元格是固定的数值可以是小数跟整数比较代码怎么写...
要比较的输入单元格B9,C9,D9。对应输出的单元格E9,F9,G9,单元格是固定的
数值可以是小数跟整数比较 代码怎么写 展开
数值可以是小数跟整数比较 代码怎么写 展开
1个回答
展开全部
Sub 比较()
Dim a(3)
For i = 0 To 2
a(i) = Cells(9, i + 2)
Next i
m = a(0)
n = a(0)
For i = 1 To 2
If m < a(i) Then m = a(i)
If n > a(i) Then n = a(i)
Next i
For i = 0 To 2
If a(i) = m Then Cells(9, i + 5) = 2
If a(i) = n Then Cells(9, i + 5) = 0
If a(i) <> m And a(i) <> n Then Cells(9, i + 5) = 1
Next i
End Sub
Dim a(3)
For i = 0 To 2
a(i) = Cells(9, i + 2)
Next i
m = a(0)
n = a(0)
For i = 1 To 2
If m < a(i) Then m = a(i)
If n > a(i) Then n = a(i)
Next i
For i = 0 To 2
If a(i) = m Then Cells(9, i + 5) = 2
If a(i) = n Then Cells(9, i + 5) = 0
If a(i) <> m And a(i) <> n Then Cells(9, i + 5) = 1
Next i
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询