Application.Worksheetfunction.Match and Array question

bdepolo

New Member
Joined
Apr 20, 2010
Messages
19
I have no idea if this is the most efficient way of doing this but I have a range of values within a worksheet that I want to compare to the values in a dynamic array and see if there are any matches. At which point some code would run.

My question is: Is it possible to even run WorksheetFunction.Match on an Array? It's executing the code for every value within my for loop. I'm not terribly familiar with WorksheetFunction.Match (only used it once) and can't find much on if I've gotten the syntax right.

I'm also open to suggestions, this was just the first thing that came to mind (which I find is usually not the most efficient way to do things).

Thanks in advance!

Code Below:

Code:
For s = 10 To xlLastRow
     If Application.WorksheetFunction.Match(Range("H" & s).Value, _
             pcband1(), 0) 
     Then
                'Execute Code
     End If
Next s
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Yes, but you need to remove the WorksheetFunction part in able to test the result for an error:

Code:
    For s = 10 To xlLastRow
        If Not IsError(Application.Match(Cells(, "H").Value, pcband1, 0)) Then
            'Execute Code
        End If
    Next s
 
Upvote 0
You're welcome, thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,614
Messages
6,179,906
Members
452,949
Latest member
beartooth91

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