I am getting the mentioned error when executing the following line of code:
Check_Row = Application.WorksheetFunction.Match(ActiveCell, Application.WorksheetFunction.Index(Selection, 0, 1), 0)
Both my ActiveCell and Selection seem to be correctly defined - ActiveCell contains some text, and the first Column of Selection contains a cell with the value match of ActiveCell. Also, when I try to run almost the same code (below) in a freshly opened excel sheet, it is working fine?
Sub Test()
Range("start").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
test_selection = Selection
Range("A8").Select
Check_Row = Application.WorksheetFunction.Match(ActiveCell,Application.WorksheetFunction.Index(test_selection, 0, 1), 0)
Range("A9").Value = Check_Row
End Sub
Does anyone have an idea what I might be overlooking here? What could be causing this issue?
Option Explicit
on top. Declare all variables. Have a look at stackoverflow.com/a/27302888/11683, then stackoverflow.com/q/10714251/11683. – GSerg Jan 23 '19 at 12:24test_selection = Selection
copies the cells' values into an array instead or remembering reference to the range), but it works. If it does not for you, it is only becauseMatch
does not find anything. – GSerg Jan 23 '19 at 12:56