# Wrong Match

#### aaronward

##### Board Regular
ok, i have now moved to a match routine. Heres my code and data:

Column G:
1
3
5
7
9

Code:
``````Dim r as Byte, Results as Boolean
For r = 1 To 10

Results = Application.WorksheetFunction.IsNA(Application.WorksheetFunction.Match(r, Range("G4:G20"), 1))
If Results Then
MsgBox "No Match" & vbCr & r
Else
MsgBox "Matches" & vbCr & r
End If
Next r``````

i have manipulated the function to return true/false for IsNA, IsError, IsNumber. i have made sure my full range is declared as 'Number" with no decimal places. The results can never find where it does not match. ANY SUGGESTIONS is greatly appreciated! Thanks!

### Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Change

Results = Application.WorksheetFunction.IsNA(Application.WorksheetFunction.Match(r, Range("G4:G20"), 1))

To

Results = Application.WorksheetFunction.IsNA(Application.WorksheetFunction.Match(r, Range("G4:G20"), 0))

yes, im sorry, that was one of many results i have tried, i have tried -1,0,1. all return same results, but thanks for the input!

Aaron

Try this instead:

Code:
``````Dim r as Integer, Results as Long
On Error Resume Next
For r = 1 To 10
Results = Application.WorksheetFunction.Match(r, Range("G4:G20"), 0)
If Err>0 Then
MsgBox "No Match" & vbCr & r
Else
MsgBox "Matches" & vbCr & r
End If
Err.Clear
Next r
On Error Goto 0``````

Hope this helps!

Richard

THANK YOU VERY MUCH!!!
That works perfectly! Thank you!

Replies
4
Views
134
Replies
7
Views
218
Replies
11
Views
392
Replies
3
Views
154
Replies
5
Views
547

Threads
1,203,313
Messages
6,054,696
Members
444,741
Latest member
MCB024

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

### Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

### Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back