I have an array prLst that is a list of integers. The integers are not sorted, because their position in the array represents a particular column on a spreadsheet. I want to know how I find a particular integer in the array, and return its index.
There does not seem to be any resource on showing me how without turning the array into a range on the worksheet. This seems a bit complicated. Is this just not possible with VBA?
Updated to show using Match (with .Index) to find a value in a dimension of a two-dimensional array:
EDIT: it’s worth illustrating here what @ARich pointed out in the comments – that using
Index()to slice an array has horrible performance if you’re doing it in a loop.In testing (code below) the Index() approach is almost 2000-fold slower than using a nested loop.