Hello guys,

I am trying to create a multidimensional array. I want to go through the headers of a specific range and if the values equal another one specified for them.

In the end I want to get the values in the array and copy them to another sheet.

I can do this with a range but I want to use an array because its faster.

This is the code I have so far.

Sub createList()

Dim arr() As Variant
Dim arrHeaders As Variant
Dim lRow As Long
Dim sh As Worksheet
Dim r As Range


' Headers I want to keep
lRow = Sheets("Orders").Range("C1").CurrentRegion.Rows.Count


arrHeaders = Array("Sales order", "Name", "Record", "Order type")
ReDim arr(1 To lRow, 1 To UBound(arrHeaders))
'Loop through the headers to pic the corrct ones


For i = 1 To Sheets("Orders").Cells(1, Columns.Count).End(xlToLeft).Column
    For j = 0 To UBound(arrHeaders)
        If Cells(1, i).Value = arrHeaders(j) Then
            ' I need to figuere out this part.
            arr = Cells(1, i).Resize(UBound(arr, 1), 1).Value
        End If
    Next
Next


End Sub
Thanks