我正在尝试编写“ if或”语句来比较六行中的单元格(A1与B1比较,B1至C1,依此类推)。不知何故,我的if或statement似乎不起作用。有人可以帮忙检查我的代码吗?
IconStar.js
跟进,问题已经解决,感谢大家的帮助!
Dim I As Byte
I = 2
If Range("b" & I) - Range("c" & I) > 0 _
Or Range("c" & I) - Range("d" & I) > 0 _
Or Range("d" & I) - Range("e" & I) > 0 _
Or Range("e" & I) - Range("f" & I) > 0 _
Or Range("f" & I) - Range("g" & I) > 0 _
Then
Range("h" & I).Value = y
Else
Range("h" & I).Value = N
End If
I = I + 1
答案 0 :(得分:3)
这可能更容易理解:
Dim theColumn as Long
For theColumn = 2 to 6 'compare columns B-G
Dim higher as Boolean
higher = Cells(I,theColumn).Value - Cells(I,theColumn+1).Value > 0
If higher Then Exit For
Next
Cells(I,"H").Value = higher
'Cells(I,"H").Value = Iif(higher,"Y","N")