我有一个运行良好的代码,除了一个缺陷。它检查范围内的文本并返回相邻单元格中的文本。如果相邻的范围行(列 C 到 G)为空,我希望它返回一个空白单元格(列 B )。这是下面的代码
Sub status_summary()
Dim r As Integer
Dim fail As Boolean
Dim mrit As Boolean
Dim pass As Boolean
For r = 2 To 6
If Range("C" & r) = "Failed" Then fail = True
If Range("C" & r) = "Merit" Then mrit = True
If Range("C" & r) = "Pass" Then pass = True
If Range("D" & r) = "Failed" Then fail = True
If Range("D" & r) = "Merit" Then mrit = True
If Range("D" & r) = "Pass" Then pass = True
If Range("E" & r) = "Failed" Then fail = True
If Range("E" & r) = "Merit" Then mrit = True
If Range("E" & r) = "Pass" Then pass = True
If Range("F" & r) = "Failed" Then fail = True
If Range("F" & r) = "Merit" Then mrit = True
If Range("F" & r) = "Pass" Then pass = True
If Range("G" & r) = "Failed" Then fail = True
If Range("G" & r) = "Merit" Then mrit = True
If Range("G" & r) = "Pass" Then pass = True
If pass = True Then Range("B" & r) = "Pass"
If mrit = True Then Range("B" & r) = "Merit"
If fail = True Then Range("B" & r) = "Failed"
fail = False
mrit = False
pass = False
Next r
MsgBox ("All Done")
End Sub