【发布时间】:2019-04-25 17:40:01
【问题描述】:
我有一个改编自此处 (https://wellsr.com/vba/2016/excel/use-isempty-vba-to-check-if-cell-is-blank/) 的 excel vba 代码,用于确定给定范围内的任何单元格是否为空白。如果有则返回 msgbx,如果没有则返回不同的 msg。
我想知道是否可以(在 msgbx 中)返回同一行 E 列中单元格的内容。这将指示需要处理的具有空单元格的行。
它查看两列。理想情况下,如果同一行中的两个单元格都是空的,它只会返回 E 列中单元格的内容一次。
这是代码,你们能帮我修改一下吗?
Sub IsEmptyRange()
Dim cell As Range
Dim bIsEmpty As Boolean
bIsEmpty = False
For Each cell In Range("G26:H38,G25,G23:H24,G22,G6:H21,G5,G3:H4")
If IsEmpty(cell) = True Then
'An empty cell was found. Exit loop
bIsEmpty = True
Exit For
End If
Next cell
If bIsEmpty = True Then
MsgBox "One or more cells are empty"
Else
MsgBox "All cells are filled in"
End If
End Sub
谢谢!
增强现实
【问题讨论】: