The Problem I found was when you declare your column Array you used a "7" as opposed to "1 to 7". This returned an array "0 to 6".
When I changed it to "1 to 7" , all seven columns showed
I've also altered the code to express the ranges (my ranges are only 7 columns with 10 rows) as Variant arrays as you will see, that way you don't need to redim then because the size of the array is already taken care off by being a Variant array.
You can also refer to the dimensions of your susequent arrays by the the Ubound values for these initail arrays.
Sub MG18Apr14
Dim a As Integer
Dim a2 As Integer
Dim b As Integer
Dim b2 As Integer
Dim BvalMx As Variant
Dim ZvalMx As Variant
' Dim CtB As Integer
' Dim CtZ As Integer
' Dim CtAll As Integer
'
' CtB = 100
' CtZ = 190
' CtAll = CtB + CtZ
'ReDim BValMx(1 To CtB, 1 To 7) As Variant
'ReDim ZValMx(1 To CtZ, 7) As Variant
'BValMx = Range("BA4:BG103")
'ZValMx = Range("BI4:BO193")
'Declare as Variant array as below
BvalMx = Range("A1:G10")
ZvalMx = Range("I1:O10")
ReDim Val(1 To UBound(BvalMx, 1) + UBound(ZvalMx, 1), 1 To 7) As Variant
ReDim PV(1 To UBound(BvalMx, 1) + UBound(ZvalMx, 1), 1) As Variant
ReDim SortPV(1 To UBound(BvalMx, 1) + UBound(ZvalMx, 1), 1) As Variant
'Stack one matrix on top of the other
For a = 1 To UBound(BvalMx, 1)
For b = 1 To 7
Val(a, b) = BvalMx(a, b)
Next b
Next a
For a2 = 1 To UBound(ZvalMx, 1)
For b2 = 1 To 7
Val(UBound(BvalMx, 1) + a2, b2) = ZvalMx(a2, b2)
Next b2
Next a2
PV = WorksheetFunction.Index(Val, 0, 7)
MsgBox Val(1, 7)
MsgBox PV(1, 1)
Range("A12").Resize(UBound(BvalMx, 1) + UBound(ZvalMx, 1), UBound(BvalMx, 2)) = Val
End Sub
Regards Mick
Bookmarks