Application match 1d array that contains 2d arrays

YasserKhalil
PlatinumLounger
Posts: 4913
Joined: 31 Aug 2016, 09:02

Application match 1d array that contains 2d arrays

Post by YasserKhalil »

Hello everyone

I have three 2d arrays and I used 1d array to store those 2d arrays like that

Code: Select all

arrResults = Array(w1, w2, w3)
Then I used a loop using a varaible e like that

Code: Select all

For Each e In arrResults
Then the problem when trying to use Application.Match to get the index number of the 2d array inside the arrResults

Code: Select all

Application.Match(e, arrResults, 0)
How can I return the index ot the the item e?
Untitled.png
You do not have the required permissions to view the files attached to this post.

YasserKhalil
PlatinumLounger
Posts: 4913
Joined: 31 Aug 2016, 09:02

Re: Application match 1d array that contains 2d arrays

Post by YasserKhalil »

I could solve it by using another 1d array to make it more flexible

Code: Select all

            arrResults = Array(w1, w2, w3)
            arrCols = Array(0, 1, 4)
            For i = LBound(arrResults) To UBound(arrResults)
                .Cells(2, iCol + arrCols(i)).Resize(UBound(arrResults(i), 1), UBound(arrResults(i), 2)).Value = arrResults(i)
            Next i