excel - 如何在点击 Then 和 End If 语句之前退出 If?
问题描述
我需要一种在“那么”之前结束“如果”的方法
For i = 0 To Main.[B10000].End(xlUp).Row - 4
POD = Trim(Main.Range("B5").Offset(i, 0))
If POD <> "" Then
L2 = "https:/AAAAA" & POD
P.Open "Get", L2
P.SetAutoLogonPolicy 0
P.send
P.waitForResponse
D.body.innerHTML = P.responseText
For Each R In D.getElementsByClassName("col-md-7")
If InStr(1, R.innerText, "pod is not found on floor") <> 0 Then
Main.Range("B5").Offset(i, 1) = "Offline"
**'I need end here if = Offline**
Else
Main.Range("B5").Offset(i, 1) = "Online"
End If
Next R
End If
Next i
End Sub
解决方案
正如 AJD 提到的,您可以在将 B5 单元格的值设置为“离线”后退出
For i = 0 To Main.[B10000].End(xlUp).Row - 4
POD = Trim(Main.Range("B5").Offset(i, 0))
If POD <> "" Then
L2 = "https:/AAAAA" & POD
P.Open "Get", L2
P.SetAutoLogonPolicy 0
P.send
P.waitForResponse
D.body.innerHTML = P.responseText
For Each R In D.getElementsByClassName("col-md-7")
If InStr(1, R.innerText, "pod is not found on floor") <> 0 Then
Main.Range("B5").Offset(i, 1) = "Offline"
Exit For
Else
Main.Range("B5").Offset(i, 1) = "Online"
End If
Next R
End If
接下来我
推荐阅读
- regex - 提取方括号之间的两个文本之间的字符串
- scala - 在控制器 NonFatal 中捕获异常
- flutter - Flutter:需要解释为什么 Expanded() 修复了由 Row() 小部件作为受约束的 Column() 小部件的子级引起的异常
- java - 带有 RestAssured 的 GitLab API 分页。如何在一个响应中获取所有页面?
- c# - Unity - 如何使用参数字典而不是带有 HttpWebRequest 的字符串
- database - 跨容器集群的连接池(数据库或其他服务)
- javascript - 使用 vuejs 时,没有在 html 文件中导入 firebase 脚本标签
- c# - C# Socket:服务器不发送消息
- java - java.lang.NumberFormatException:调用端口 curl 调用时为 null
- c# - 如何解决 C# 控制台应用程序中的 DLL 劫持问题