Wrong Match

aaronward

Board Regular
Joined
Aug 2, 2006
Messages
165
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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
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))
 
Upvote 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!
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,226,496
Messages
6,191,368
Members
453,655
Latest member
lasvegasbuffet

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

Which adblocker are you using?

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
Back
Top