【发布时间】:2021-11-06 06:16:11
【问题描述】:
我没有评估“等于”的逻辑运算符
Dim Stage As String
If Range("I5") = "si" Then
Stage = "E"
ElseIf Range("I5") = "no" And Range("I9") > 1020 And Range("I9") <= 3100 Then
Stage = "
Execution of leasehold adjustments to existing infrastructure for use and operation for 10 years."
ElseIf Range("I5") = "no" And Range("I9") > 3101 Then
Stage = "Construction and operation of a collection center for recyclable waste for 10 years."
ElseIf Range("I5") = "si" And Range("I9") <= 1020 Then
Stage = "Construction and operation of a collection center for recyclable waste for 10 years.."
ElseIf Range("I5") = "si" And Range("I9") > 1020 And Range("I9") <= 3100 Then
Stage = "Stage Simulation 1: Construction and operation of a collection center for recyclable waste for 10 years."
ElseIf Range("I5") = "si" And Range("I9") > 3101 Then
Stage = "Stage Simulation 1: Construction and operation of a collection center for recyclable waste for 10 years."
End If
他们知道我的代码有什么问题
【问题讨论】:
-
单步执行,看看它在做什么。猜测
If声明都不是真的,所以它就结束了。 -
如果
I5中包含si,则不会执行任何ElseIf 语句。 -
请说明您是如何测试的,哪些输入值( Range("I5") 和 Range("I9") )给出了意外的结果( Stage )?
-
按照 Warcupine 的建议,在第一个
If处设置一个断点,然后逐步执行:google.com/search?q=vba+step+through+code
标签: excel vba if-statement