excel - 连续检查负值
问题描述
我正在尝试使用以下 vba 代码来检查Excel 工作表的第 1 行中带有数字的负值1, 2, -3, 4, 5, 6
。宏应该选择-3
值并停在那里。不幸的是,它不起作用。发生错误告诉我End If without block If
。看不到我的错误。
Sub SelectNegativeValue()
Dim Cell As Range
For Each Cell In Range("1:1")
If Cell.Value < 0 Then Cell.Select
Exit For
End If
Next Cell
End Sub
解决方案
宏应该选择“-3”值并停在那里。
你需要移动Cell.Select
到下一行......就在之前Exit For
Dim Cell As Range
For Each Cell In Range("1:1")
If Cell.Value < 0 Then
Cell.Select
Exit For
End If
Next Cell
推荐阅读
- python - 无效的文件路径或缓冲区对象类型:
- c# - 如何自动调整网格中内容的大小以使其适合所有分辨率
- excel - 仅键盘格式刷非相邻单元格 Excel
- token - Google reCAPTCHA v3 找不到任何令牌
- javascript - @input 在相同组件角度问题的不同实例中
- kubernetes - 使用 terraform 动态连接到 GKE 集群
- javascript - firebase 创建用户承诺
- python - 使用Biopython从python中的.fasta基因中提取基因起始位置
- javascript - 无法找到按钮以查找其禁用状态以进行测试
- python - 文本未知原因的 Tkinter 消息换行