Application.WorksheetFunction.Match only sometimes working?

GBagley

Board Regular
Joined
Feb 8, 2011
Messages
84
I've tried everything I can think of, and I'm stuck here. I've got this statement:

Counted = Application.WorksheetFunction.Match(BCC_Bin, Sheets("BCC_Counts").Range("A1", "A" & last_row_bcc), 1)



(Counted and last_row_bcc are both declared as integers). I'm working with a large dataset, and this formula only seems to work part of the time. In chunks. It's in a loop, and it will work fine for the first couple thousand passes, but then it will go through a couple hundred and return 0 every time. But when I set a break point and do:

debug.print Application.WorksheetFunction.Match(BCC_Bin, Sheets("BCC_Counts").Range("A1", "A" & last_row_bcc), 1)

I get the correct number returned, then I step through, and I get 0 again. I ensured that my source data is sorted in ascending order, and my range is getting the full range that I want. Calculationmode is set to automatic (though that shouldn't matter for VBA calculations, right?).

Any ideas?
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,947
Latest member
Gerry_F

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