Option Explicit
Public Const OutputColumnsTotal As Long = 10
Private Sub test()
Dim tempArr() As Variant
With ActiveSheet
tempArr = .Range("A1:K2").Value
tempArr = ShuffleArrayColumns(tempArr)
.Range("A5").Resize(UBound(tempArr, 1), UBound(tempArr, 2)) = tempArr
End With
End Sub
Private Function ShuffleArrayColumns(ByRef tempArr As Variant) As Variant
If Not UBound(tempArr, 2) - 1 = OutputColumnsTotal Then
Debug.Print "Array tempArr as wrong # columns in " & Application.VBE.Activecodepane.CodeModule
Exit Function
Else
Dim i As Long
Dim tempArr2() As Variant
ReDim tempArr2(1 To UBound(tempArr, 1), 1 To OutputColumnsTotal)
For i = LBound(tempArr, 1) To UBound(tempArr, 1)
tempArr2(i, 1) = Format$(tempArr(i, 9),"yyyy-mm-dd") 'to preserve UK date format. Sheet is formatted to display "mmm-yy".
tempArr2(i, 2) = tempArr(i, 10)
tempArr2(i, 3) = tempArr(i, 11)
tempArr2(i, 4) = tempArr(i, 2)
tempArr2(i, 5) = tempArr(i, 3)
tempArr2(i, 6) = tempArr(i, 1)
tempArr2(i, 7) = tempArr(i, 4)
tempArr2(i, 8) = tempArr(i, 5)
tempArr2(i, 9) = tempArr(i, 6)
tempArr2(i, 10) = tempArr(i, 7)
Next i
End If
ShuffleArrayColumns = tempArr2
End Function