VBA WorksheetFunction.Match problem

TdotW

New Member
Joined
Feb 15, 2017
Messages
7
Hi I have a dynamic range of cells that contain information belonging in another table. I'm trying to use the WorksheetFunction.Match to find the row position in the other table but I keep getting returned the same value.

Code:
 For i = 2 To NumOfRows
[INDENT]    Worksheets(2).Range("R" & i).Value = _ 
 Application.WorksheetFunction.Match("Q" & i, Batches)[/INDENT]
Next I

Batches is the reference table range.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Does this work?
Code:
 For i = 2 To NumOfRows
    Worksheets(2).Range("R" & i).Value = Application.Match(Range("Q" & i), Batches, 0)
Next I
 
Last edited:
Upvote 0
Your code is matching the lilteral text "Q2", "Q3" and so on, not the contents of those cells. I imagine you want:

Code:
Application.WorksheetFunction.Match(Range("Q" & i), Batches)

Note also that this is an approximate match, not an exact match.
 
Upvote 0

Forum statistics

Threads
1,214,655
Messages
6,120,760
Members
448,991
Latest member
Hanakoro

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