ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Array Question (https://www.excelbanter.com/excel-programming/394591-array-question.html)

Mike H.

Array Question
 
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?

RB Smissaert

Array Question
 
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 H." wrote in message
...
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?



Alan Beban

Array Question
 
Mike H. wrote:
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

John Bundy

Array Question
 
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
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Mike H." wrote:

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?



All times are GMT +1. The time now is 11:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com