我试图为每个'运行一个非常简单的嵌套'在VBA;但是语法错误。当我在第二个For-Each(PropFromOutput = O.Value)之后删除该行时,它可以正常工作。我哪里做错了? 谢谢。
Sub CompareAndMark()
Dim Linko As Worksheet
Dim Output As Worksheet
Dim PropFromLinko As String
Dim PropFromOutput As String
For Each L In Linko.Range("B2:B69").Cells
PropFromLinko = L.Value
For Each O In Output.Range("A2:A69").Cells
PropFromOutput = O.Value
Next O
Next L
End Sub
答案 0 :(得分:2)
Sub CompareAndMark()
Dim Linko As Worksheet
Dim Output As Worksheet
Dim PropFromLinko As String
Dim PropFromOutput As String
Set Linko = ActiveSheet
Set Output = ActiveSheet
For Each L In Linko.Range("B2:B69").Cells
PropFromLinko = L.Value
For Each O In Output.Range("A2:A69").Cells
PropFromOutput = O.Value
Next O
Next L
End Sub
这将编译并运行OK(尽管L
和O
值为空,但我不知道您的完整代码)。您失败的原因是因为您从未设置Worksheet
Linko
& Output
设置为。请根据需要编辑分配给他们的工作表,以使其适合您