Results 1 to 7 of 7

jagged arrays

Threaded View

  1. #1
    Forum Contributor
    Join Date
    07-13-2017
    Location
    Hong Kong
    MS-Off Ver
    MS Office 365
    Posts
    481

    jagged arrays

    Hi all,

    I need to merge three 2D arrays into one. I have arry1, 2 and 3 which come from three different sheets, they are all of the same size. Now I want to create a consolidated array with all unique Materials of the three arrays and if the Material is not unique I want to replace all data points that contain " - " with whatever the matched array contains (either " x " or " - " as well).

    I created a simplified sample workbook to illustrate things further with a "desired output" sheet to show how the end result should look like. Below is the code I have so far to combine at least 2 of these arrays, however, that also doesn't seem quite right yet as some Materials are overwritten or neglected.

            Dim Concat()
            Dim size As Long
                
            ReDim Concat(1 To UBound(arry1, 1), 1 To UBound(arry1, 2))
                
            For i = LBound(arry1, 1) To UBound(arry1, 1)
                On Error Resume Next
                Dim MtchRw As Long
                MtchRw = Application.Match(arry1(i, 1), Application.Index(arry2, , 1), 0)
                If Err.Number <> 0 Then MtchRw = 0
                Err.Clear
                On Error GoTo 0
                size = size + 1
                For j = LBound(arry1, 2) To UBound(arry1, 2)
                    If MtchRw <> 0 Then
                        Dim Cont As Variant
                        Cont = arry2(MtchRw, j)
                        If Cont = " - " Then
                            Concat(size, j) = arry1(i, j)
                        Else
                            Concat(size, j) = arry2(MtchRw, j)
                        End If
                    Else
                        Concat(size, j) = arry1(i, j)
                    End If
                Next j
            Next i
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Using jagged array to associate one to many
    By tobias1010 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-14-2018, 11:01 PM
  2. Jagged Array vba
    By tobias1010 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-12-2018, 01:37 PM
  3. [SOLVED] Jagged Arrays: Syntax Clarificatiuon
    By cmore in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-26-2016, 05:46 PM
  4. Declaring multiple multi-dimensional arrays (jagged arrays) - compile error?
    By dfribush in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-20-2013, 05:06 PM
  5. [SOLVED] Print to worksheet and Jagged Array
    By abousetta in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-07-2012, 07:50 PM
  6. Jagged Pie Charts
    By Sionos in forum Excel General
    Replies: 0
    Last Post: 09-25-2007, 05:54 AM
  7. [SOLVED] soften jagged edges of pie charts
    By zen in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 06-17-2005, 02:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1