我有这段代码,但似乎无法解决问题,
Sub IndMat()
Dim wh1 As Worksheet
Dim wh2 As Worksheet
Set wh1 = Sheets("SAS")
Set wh2 = Sheets("Sheet1")
Dim y As VariantDim x As LongDim lr1 As Long
Dim lr2 As Long
Dim rng1 As Range
Dim rng2 As Range
lr1 = wh1.Cells(Rows.Count, 5).End(xlUp).Row
lr2 = wh2.Cells(Rows.Count, 2).End(xlUp).Row
Set rng1 = wh2.Range("a2:a25")
Set rng2 = wh2.Range("b2:b25")
For i = 2 To lr1
y = application.Index(rng1, Application.Match(wh1.Cells(i, 5), rng2, 0))
Next i
End Sub
运行时出现错误
y = application.Index(rng1, Application.Match(wh1.Cells(i, 5), rng2, 0))