Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default ARRAY SEARCH PROBLEM !!!

Hi -

I have 2 arrays: ArrA and ArrB. Each slot in each array contains
characters delimited by comma ",". I need to check if for every slot
content in ArrA, all members of any slot(s) in ArrB are there. ArrA and
ArrB don't necessarily have the same size or length.I just used array
lengths of 3 for ArrA and 4 for ArrB for simplicity but the actual
array slots can be lengthier.

Example:
If ArrA contains:
ArrA(0)= A,BB,C,FF,X
ArrA(1)= 88,VV,J,B,79
ArrA(2)= U,KL,MN,6,44
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 199
Default ARRAY SEARCH PROBLEM !!!

This is one way, though this doesn't satisfy your request for having
minimum loops or even no loops, but rather having maximum loops.

Sub Searchtest()
Dim ArrA(2), ArrAA
Dim ArrB(3), ArrBB
Dim i As Long, j As Long, k As Long
Dim found As Boolean

ArrA(0) = "A,BB,C,FF,X"
ArrA(1) = "88,UU,J,B,79"
ArrA(2) = "U,KL,MN,6,44"
ArrB(0) = "10,B,CC"
ArrB(1) = "C,A,FF"
ArrB(2) = "44,KL,MN"
ArrB(3) = "79,88,B"

For i = 0 To UBound(ArrA)
For j = 0 To UBound(ArrB)
found = True
ArrAA = Split(ArrA(i), ",")
ArrBB = Split(ArrB(j), ",")
For k = 0 To UBound(ArrBB)
If IsError(Application.Match(ArrBB(k), ArrAA, 0)) Then
found = False
Exit For
End If
Next
If found Then
MsgBox ArrB(j) & " Found in ArrA(" & i & _
") = { " & ArrA(i) & " }"
End If
Next
Next
End Sub

Keiji

jay dean wrote:
Hi -

I have 2 arrays: ArrA and ArrB. Each slot in each array contains
characters delimited by comma ",". I need to check if for every slot
content in ArrA, all members of any slot(s) in ArrB are there. ArrA and
ArrB don't necessarily have the same size or length.I just used array
lengths of 3 for ArrA and 4 for ArrB for simplicity but the actual
array slots can be lengthier.

Example:
If ArrA contains:
ArrA(0)= A,BB,C,FF,X
ArrA(1)= 88,VV,J,B,79
ArrA(2)= U,KL,MN,6,44
.
.
.

And ArrB contains:
ArrB(0)= 10,B,CC
ArrB(1)= C,A,FF
ArrB(2)= 44,KL,MN
ArrB(3)= 79,88,B
.
.
.
Then I want to take ArrB(0),ArrB(1),ArrB(2),ArrB(3) and compare EACH to
ArrA(0). If ALL the elements in any ArrB(x) are found in ArrA(0) then a
messgBOx will show those found to be subsets. In this case, only
elements of ArrB(1) are all found in Arr(0)... so we'll have Msgbox
'C,A,FF found'

Then the macro will compare ArrB(0),ArrB(1),ArrB(2),ArrB(3) with
ArrA(1). In this case, only elements of ArrB(3) can all be found in
ArrA(1), so message box shows "79,88,B found'. Then we will compare all
the ArrB to ArrA(2), ArrA(3), etc.. whenever ALL elements of ANY ArrB
slot(s) are found in ANY element in ArrA, the Msgbox shows up with the
subsets names.

I think this will be a little tough but I am looking for a solution with
minimum loops or even no loops (if at all possible).

Any help will be appreciated.

Thanks
Jay Dean



*** Sent via Developersdex http://www.developersdex.com ***

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
search array jchick0909 Excel Worksheet Functions 3 October 5th 07 07:25 PM
search an array for values contained in another array Cheer-Phil-ly Excel Programming 0 April 12th 07 09:44 PM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 6 November 9th 05 05:54 AM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 1 November 8th 05 04:21 AM
SEARCH EXCEL ARRAY FOR NON-VOIDS AND ENTER INTO ANOTHER ARRAY, ROSE THE RED Excel Programming 1 December 31st 04 06:01 PM


All times are GMT +1. The time now is 03:21 AM.

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"