Run time error '1004' Unable to get the Ma

2020-05-03 13:07发布

nSectionSetupRow = Application.WorksheetFunction.Match( _
      Worksheets("Items").Cells(nRow, 1), _
      Worksheets("SectionSetup").Range("B1:B" & _
      Worksheets("SectionSetup").Range("A1").End(xlDown).Row), 0)

i am facing issue here and using excel 97-2003 worksheet type of excel

标签: excel vba
1条回答
甜甜的少女心
2楼-- · 2020-05-03 13:46

Application.WorksheetFunction.Match will raise a run-time error if there's no match.

Application.Match will instead return an error value which you can test for using IsError()

E.g:

Dim m 'variant
m = Application.Match(lookupValue, lookupRange, 0)
If Not IsError(m) Then
    'got a match
Else
    'no match
End If
查看更多
登录 后发表回答