Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Finding a match- should i use a nested array, my source arrays, or

I have several arrays of products, each with a different number of items
fruit= Array("apples", "pears", "peaches")
pasta= Array("lasagna", "elbow", "bowtie", "penne", "orzo")
IceCream= Array("chocolate","vanilla")
[etc]

Which I've also thrown into one nested array (I'm not sure I needed to- it
seemed like a good idea at the time)
AllProducts = Array(fruit, pasta, IceCream)

The product values are all unique; the same product will not show up more
than once in an array, nor will it show up in more than one array.

I'm now cycling through a large body of raw data, trying to identify records
that match any of the values in my array. So for example, I might come across
a value of "vanilla". I need to identify if that value is in any of my
arrays, and if so, which array it is in, and which position it is in that
array. Once I know the position, I'll take other data from that same source
data row for my calculations (last order date, order quantity, etc.) to
aggregate by product and product group.

My limited experience suggests that I use the orginal arrays directly, maybe
with application.match to identify if it is in any component array. Is there
any benefit (speed, simplicity, or eloquence) to using a nested array to find
matched values, or am I better off sticking with the individual arrays? Or is
there some better way of doing this in Excel that I haven't learned yet?

Thank you!
Keith
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Finding a match- should i use a nested array, my source arrays, or

You wont get a match in an array of arrays like that, so you would have to
check each item

fruit = Array("apples", "pears", "peaches")
pasta = Array("lasagna", "elbow", "bowtie", "penne", "orzo")
IceCream = Array("chocolate", "vanilla")
AllProducts = Array(fruit, pasta, IceCream)

lookup = "vanilla"
On Error Resume Next
For i = LBound(AllProducts) To UBound(AllProducts)

idx = Application.Match(lookup, AllProducts(i), 0)
If idx 0 Then

MsgBox "Found in item (" & i & ")(" & idx & ")"
Exit For
End If
Next i

--
__________________________________
HTH

Bob

"ker_01" wrote in message
...
I have several arrays of products, each with a different number of items
fruit= Array("apples", "pears", "peaches")
pasta= Array("lasagna", "elbow", "bowtie", "penne", "orzo")
IceCream= Array("chocolate","vanilla")
[etc]

Which I've also thrown into one nested array (I'm not sure I needed to- it
seemed like a good idea at the time)
AllProducts = Array(fruit, pasta, IceCream)

The product values are all unique; the same product will not show up more
than once in an array, nor will it show up in more than one array.

I'm now cycling through a large body of raw data, trying to identify
records
that match any of the values in my array. So for example, I might come
across
a value of "vanilla". I need to identify if that value is in any of my
arrays, and if so, which array it is in, and which position it is in that
array. Once I know the position, I'll take other data from that same
source
data row for my calculations (last order date, order quantity, etc.) to
aggregate by product and product group.

My limited experience suggests that I use the orginal arrays directly,
maybe
with application.match to identify if it is in any component array. Is
there
any benefit (speed, simplicity, or eloquence) to using a nested array to
find
matched values, or am I better off sticking with the individual arrays? Or
is
there some better way of doing this in Excel that I haven't learned yet?

Thank you!
Keith



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Finding a match- should i use a nested array, my source arrays

Thanks Bob- this works great!
Best,
Keith

"Bob Phillips" wrote:

You wont get a match in an array of arrays like that, so you would have to
check each item

fruit = Array("apples", "pears", "peaches")
pasta = Array("lasagna", "elbow", "bowtie", "penne", "orzo")
IceCream = Array("chocolate", "vanilla")
AllProducts = Array(fruit, pasta, IceCream)

lookup = "vanilla"
On Error Resume Next
For i = LBound(AllProducts) To UBound(AllProducts)

idx = Application.Match(lookup, AllProducts(i), 0)
If idx 0 Then

MsgBox "Found in item (" & i & ")(" & idx & ")"
Exit For
End If
Next i

--
__________________________________
HTH

Bob

"ker_01" wrote in message
...
I have several arrays of products, each with a different number of items
fruit= Array("apples", "pears", "peaches")
pasta= Array("lasagna", "elbow", "bowtie", "penne", "orzo")
IceCream= Array("chocolate","vanilla")
[etc]

Which I've also thrown into one nested array (I'm not sure I needed to- it
seemed like a good idea at the time)
AllProducts = Array(fruit, pasta, IceCream)

The product values are all unique; the same product will not show up more
than once in an array, nor will it show up in more than one array.

I'm now cycling through a large body of raw data, trying to identify
records
that match any of the values in my array. So for example, I might come
across
a value of "vanilla". I need to identify if that value is in any of my
arrays, and if so, which array it is in, and which position it is in that
array. Once I know the position, I'll take other data from that same
source
data row for my calculations (last order date, order quantity, etc.) to
aggregate by product and product group.

My limited experience suggests that I use the orginal arrays directly,
maybe
with application.match to identify if it is in any component array. Is
there
any benefit (speed, simplicity, or eloquence) to using a nested array to
find
matched values, or am I better off sticking with the individual arrays? Or
is
there some better way of doing this in Excel that I haven't learned yet?

Thank you!
Keith




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
nested MATCH within Array formula? katy Excel Worksheet Functions 2 January 23rd 08 02:08 AM
Arrays - Nested IF with Vlookup? RV Excel Discussion (Misc queries) 3 September 25th 07 09:09 PM
finding nearest match from an array Arjun Chowdhry Excel Discussion (Misc queries) 2 April 3rd 07 05:22 PM
Offset function with nested match function not finding host ss. MKunert Excel Worksheet Functions 1 March 21st 06 10:46 PM
Nested Arrays Matt Excel Programming 2 February 27th 06 09:51 AM


All times are GMT +1. The time now is 04:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"