vba - 循环遍历范围和检查值(Excel VBA)
问题描述
我编写了一个简单的 VBA 代码来循环遍历一个范围以检查特定值,如果它是真的,那么它将一个布尔触发器切换为假。
但是,我的代码不起作用。即使我在范围内的某个位置放置了“12345”,它仍然返回 Infochk = True。
代码
Dim InfoChk As Boolean
InfoChk = True
LastRow = Sheets("Sheet1").Cells(Rows.count, "B").End(xlUp).row
For i = 7 To LR
With Worksheets("Sheet1")
If .Cells(i, 6).Value = "12345" Then
MsgBox ("gotcha")
InfoChk = False
Exit For
End If
End With
Next i
MsgBox (InfoChk)
任何帮助将不胜感激。
解决方案
推荐阅读
- javascript - 在客户端之间共享状态的服务器上的单个 JS 对象中可以存储多少数据?
- r - 如何分隔单元格中的多个数值数据值并查找每列的总数?
- azure-cosmosdb - 当 CosmosDb 说 10 毫秒写入延迟时,是否包括写入请求到达 cosmosdb 服务器所需的时间?
- android - 如何在 kapt 中设置包 ID
- python - 如何使用 Python Apache Beam 解压缩 beam.Map 中的字典值
- android - 更新flutter sdk和所有包后出错
- typescript - 尝试将 Typescript 类型用于第 3 方 Javascript 库时出现错误 TS2307
- firebase - React Native - 警告:无法从不同组件的函数体内更新组件
- vue.js - 路由器链接动态 vueJS
- c# - 在 C# LINQ ASP.NET 中更新数据库表时遇到问题