【发布时间】:2017-03-30 14:58:45
【问题描述】:
我的循环没有在整个工作表 1 中运行时遇到问题。如果工作表 1“测试”中的值存在于工作表 2“癌症”中。然后我希望将表 2“癌症”中的值放入表 1“测试”中。除循环外,该代码均有效。目前它仅适用于我的第一张表中的第一条记录,然后停止。
Sub Testing()
Dim x As Long
Dim y As Long
x = 2
y = 2
Do While Sheets("Cancer").Cells(y, 1).Value <> ""
If LCase(Trim(Sheets("Cancer").Cells(y, 1).Text)) = LCase(Trim(Sheets("Tests").Cells(x, 3).Text)) Then
If Sheets("Tests").Cells(x, 4).Value = "" Then
Cells(x, 4) = (Trim(Sheets("Cancer").Cells(y, 3).Text))
x = x + 1
End If
End If
y = y + 1
Loop
End Sub
【问题讨论】:
-
你有没有通过代码来检查发生了什么?