vbscript excel的未知运行时错误

我在第28行(如果语句)出现“”错误。 我不确定是什么问题,因为我已经正确地定义了一切,并确保path得到纠正。 有人可以帮忙吗? 我试图抓住每个用户从一张纸到另一张纸相应的组。 这里是我的代码:

for each ColValue1 in objWorksheet1.Range("A1:A" & intlastrow1) introw1= introw1+1 for each ColValue2 in objWorksheet2.Range("A1:A" & intLastRow2) introw2 = introw2+2 if ColValue1 = ColValue2 then ... 

您正在循环的单元格应该声明为一个范围。 然后比较它们的值。

 Dim ws As Excel.Worksheet Set ws = ActiveWorkbook.Sheets("Sheet1") Dim ColValue1 As Range Dim ColValue2 As Range Set ColValue1 = ws.Range("A1") Set ColValue2 = ws.Range("A2") If ColValue1.Value = ColValue2.Value Then MsgBox "They are the same" Else MsgBox "They are not the same" End If