Array Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I populate an array from data in a text file. Then I go to a spreadsheet and
I look at a cell and want to find the text in that cell in the array. Is
there an arrayfind() function to find the data that is in the cell? And can
I sort the array so that the find is faster?

Also, I populate a similar array with values. Can I have both types of data
in one array, text and values?
 
If the text file has the right layout then you could run SQL on that file.
This would save you the intermediary step of the array and is quite fast.

Yes, you can sort arrays and then do a binary search, which could be a lot
faster.

Yes, you can have variant arrays that can hold both string data and numeric
data.


RBS
 
Mike said:
I populate an array from data in a text file. Then I go to a spreadsheet and
I look at a cell and want to find the text in that cell in the array. Is
there an arrayfind() function to find the data that is in the cell?

If your array is one-dimensional or a single"column", then e.g.,
=Application.Match(Range("A3").Value, yourArray) will return the
"column" number in the array of the value that is in A3 (or the row
number if the array is a single "column").

Alan Beban
 
The array can have any values you want, with wildly different ones you would
typically dim it as Variant. as far as finding, there are ways, but the
system can probably loop through your array just as fast.
do until myArray(myindex,1)=cells(1,1)

myindex=myindex+1
loop
 
Back
Top