Run time error '1004' Unable to get the Match propertyof the WorksheetFunction class

前端 未结 6 1320
悲&欢浪女
悲&欢浪女 2021-01-17 01:29

In my macro, I have the following code :

i = Application.WorksheetFunction.Match(str_accrual, Range(Selection, Selection.End(xlToRight)), 0)
6条回答
  •  遥遥无期
    2021-01-17 02:04

    I was getting this error intermittently. Turns out, it happened when I had a different worksheet active.

    As the docs for Range say,

    When it's used without an object qualifier (an object to the left of the period), the Range property returns a range on the active sheet.

    So, to fix the error you add a qualifier:

    Sheet1.Range
    

提交回复
热议问题