ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   can I test if a variable is a member of an array (https://www.excelbanter.com/excel-programming/415867-can-i-test-if-variable-member-array.html)

Andy Clarke

can I test if a variable is a member of an array
 
I have a very large spreadsheet containing raw data for the whole world. I am
only interested in certain countries, and I have to group the countries into
market groupings, such as Benelux for Belgium, Netherlands and Luxembourg.

I have set up an array containing all the countries required (70 of them),
and several other arrays for each market grouping.

As I read through the spreadsheet, row by row, I want to test if the country
is one that I am interested in. Therefore, it would be best if there was a
function to test if the country is a member of my countries array.

At the moment, I am looping and testing if each country is member1, then
member 2, etc. Therefore, there is a 70-stage loop for each row in the
spreadsheet. And then I test again to see which market grouping they belong
to ...

There must be a much more efficient way of doing this.

Any ideas?

Thanks

Rick Rothstein \(MVP - VB\)[_2621_]

can I test if a variable is a member of an array
 
If the array you are looping through is a one-dimensional String array, then
look up the Filter function in the help files.

Rick


"Andy Clarke" <Andy wrote in message
...
I have a very large spreadsheet containing raw data for the whole world. I
am
only interested in certain countries, and I have to group the countries
into
market groupings, such as Benelux for Belgium, Netherlands and Luxembourg.

I have set up an array containing all the countries required (70 of them),
and several other arrays for each market grouping.

As I read through the spreadsheet, row by row, I want to test if the
country
is one that I am interested in. Therefore, it would be best if there was a
function to test if the country is a member of my countries array.

At the moment, I am looping and testing if each country is member1, then
member 2, etc. Therefore, there is a 70-stage loop for each row in the
spreadsheet. And then I test again to see which market grouping they
belong
to ...

There must be a much more efficient way of doing this.

Any ideas?

Thanks




All times are GMT +1. The time now is 01:25 PM.

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