VBA Match is returning the wrong row.

Solved
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?

2 answers

Patrice33740 Posted messages 8400 Registration date   Status Member Last intervention   1 783
 
Hello

The correct syntax is Rows("6:6") or more simply Rows(6)
6.6 is a decimal number rounded to 7; and 5.5 to 6; and 4.4 to 4

Best regards
Patrice
1
geo0258 Posted messages 24 Status Member
 
Sometimes we look so far when it's actually so simple. Thank you Patrice, it worked.
0