使用索引匹配时,下标超出范围

时间:2016-10-28 10:41:51

标签: excel-vba vba excel

Sub General()
Dim Generic_Selection As Range
Dim Generic As Range
Dim Models As Range
Dim All_Models As Range
Set Generic_Selection = Sheets("Report").Range("Generic_Selection")
Set Generic = Sheets("Data").Range("Generic")
Set Models = Sheets("Sheet1").Range("Models")
Set All_Models = Sheets("Data").Range("All_Models")
If Generic_Selection = "" Then
    Sheets("Sheet1").Range("Generic_Model").ClearContents
Else
    Sheets("Sheet1").Range("Generic_Model") = Application.WorksheetFunction.Index(Generic, Application.WorksheetFunction.Match(Models, All_Models, 0), 1)
End If
End Sub

有关为什么这会作为下标超出范围返回的任何想法?所有引用都是正确的,并且在没有else语句的情况下工作正常。

0 个答案:

没有答案