excel - 对多行重复代码
问题描述
我有下面的 VBA 代码,它适用于一行。我需要这个循环 100 行并为每一行做同样的工作。有人可以帮我这样做吗?
Sub IsEmptyRange()
Dim cell As Range
Dim bIsEmpty As Boolean
bIsEmpty = False
For Each cell In Range("A1:H1")
If IsEmpty(cell) = True Then
bIsEmpty = True
Exit For
End If
Next cell
If bIsEmpty = True Then
'**PLACE CODE HERE**
[I1].Value = "Empty Cells"
Else
'**PLACE CODE HERE**
[I1].Value = "Complete"
End If
End Sub
谢谢!!
解决方案
你可以尝试实现这个吗?
* = things added/changed (remove when you put in VBA)
*Dim lRow as Integer
*Dim i as Integer
*lRow = Cells(Rows.Count, 1).End(xlUp).Row
*For i = 1 to lRow
For Each cell In Range("A" & i & ":H" & i)
If IsEmpty(cell) = True Then
bIsEmpty = True
Exit For
End If
Next cell
If bIsEmpty = True Then
'**PLACE CODE HERE**
*[I & i].Value = "Empty Cells"
Else
'**PLACE CODE HERE**
*[I & i].Value = "Complete"
End If
*Next i
推荐阅读
- kotlin - Kotlin 流程 - 如何处理取消
- python-3.x - Python,使用glob列出图像,使用变量时为空列表
- reactjs - 不能在 FlatList renderItem 中使用钩子
- c++ - pop rbp 后存储在 [rbp-1] 中的值会发生什么变化
- git - 为什么我没有收到错误“致命:当前分支 A 没有上游分支”。
- node.js - 如何使用 node.js 在项目根目录之外创建目录?
- sql - 从非分区表迁移到字段分区表时的问题
- ssh - 无法在 On Premise GitLab 实例上获得 SSH 连接
- javascript - 范围内所有数字的总和始终返回 0
- power-automate - Power Automate - AWS RDS Mysql 数据库连接器