我有一个vlookup代码,在我的excel 2019中可以正常工作,但是当尝试在我的办公室PC上运行相同的代码时,会抛出类型不匹配错误。我花了很多时间来寻找解决方案,但我没有。
以下是以下代码
Sub Vlookup()
Dim lookfor As Variant
Dim rng As Range
Dim MaturedPolicies As Variant
A = Application.WorksheetFunction.CountA(Worksheets("SQL Results").Range("$B:$B"))
lookfor = Sheets("SQL Results").Range("B2:B" & A).Value
Set rng = Sheets("SQL Results").Range("$Y$2:$Y$100")
MaturedPolicies = Application.WorksheetFunction.Vlookup(lookfor, rng, 1,
False)
Application.ScreenUpdating = False
Sheets("SQL Results").Range("W2:W" & A).Value = MaturedPolicies
Application.ScreenUpdating = True
End Sub