由于撇号比较列不工作

我想用下面的代码来比较不同工作表上的两列:

For i = 2 To lastRow22 For j = 2 To lastRow33 If ws2.Cells(i, 81) = ws3.Cells(j, 10) Then ws2.Cells(i, 1).Interior.Color = vbGreen End If Next j Next I 

我知道列中的项目匹配,但循环似乎没有find匹配。 我进一步检查了柱子,在一张纸上,柱子都是撇号,而另一张却没有。

我试着在表格中循环,用下面的代码删除撇号,但是它不起作用:

 For i = 2 To lastRow33 If ws3.Cells(i, 10) Like "'*" Then x = Replace(ws2.Cells(i, 1), "'", "") ws3.Cells(i, 10) = x End If Next I 

有关我可以做什么来获得比赛的任何提示?

在比较之前使用Cstr将所有内容转换为string。 这适用于string以及数字,所以没有types不匹配错误。

最终代码:

 For i = 2 To lastRow22 For j = 2 To lastRow33 If Cstr(ws2.Cells(i, 81)) = Cstr(ws3.Cells(j, 10)) Then ws2.Cells(i, 1).Interior.Color = vbGreen End If Next j Next i