VBA Match is returning the wrong row.
Solved
geo0258
Posted messages
24
Status
Member
-
geo0258 Posted messages 24 Status Member -
geo0258 Posted messages 24 Status Member -
Good evening everyone. I've been agonizing for several hours trying to understand why a very simple match application in VBA is giving me a 2042 error.
After multiple attempts at rewriting, changing formats, etc., I realized that error 2042 means it can't find the result. So I randomly tested to see if Excel was looking for the result in the right row. I finally found that: while I was asking to match in row 6 (which I wrote as rows("6, 6")), Excel was giving me the result from row 7. So when I replaced rows("6, 6") with rows("5, 5") in my VBA formula, I found the result I wanted even though it's actually in row 6 in Excel.
I tested all the rows starting from row 1 and the offset starts from row 4. I have no idea why or how this is happening, I've tried unfreezing panes, copying the sheet into a new file, but nothing works. Any ideas? Has anyone encountered this kind of problem before?
After multiple attempts at rewriting, changing formats, etc., I realized that error 2042 means it can't find the result. So I randomly tested to see if Excel was looking for the result in the right row. I finally found that: while I was asking to match in row 6 (which I wrote as rows("6, 6")), Excel was giving me the result from row 7. So when I replaced rows("6, 6") with rows("5, 5") in my VBA formula, I found the result I wanted even though it's actually in row 6 in Excel.
I tested all the rows starting from row 1 and the offset starts from row 4. I have no idea why or how this is happening, I've tried unfreezing panes, copying the sheet into a new file, but nothing works. Any ideas? Has anyone encountered this kind of problem before?