There are two routines, the first fills the array Matriz. However Matriz is declared so that it is scoped only to the procedure level. One the Sub GenerateMatriz is finished, the variable Matriz passes out of scope and loses its value.
There are two ways to approach this.
One way would be to declare Matriz as a Public variable, so it will be in scope when execution returns to Test.
Note that the declaration Publid Matriz() As Integer is before any of the routines in that module
Public Matriz() As Integer
Sub GenerateMatriz()
Dim SumaTotalCamiones, TotalClase, i As Integer
i = 0
TotalClaseA = Worksheets("hoja1").Cells(4, 1).Value
TotalClaseB = Worksheets("hoja1").Cells(4 + 1, 1).Value
TotalClaseC = Worksheets("hoja1").Cells(4 + 2, 1).Value
SumaTotalCamiones = Worksheets("hoja1").Cells(4, 1).Value + Worksheets("hoja1").Cells(5, 1).Value + Worksheets("hoja1").Cells(6, 1).Value
ReDim Matriz(SumaTotalCamiones - 1, 3)
' etc
End Sub
Sub Test()
GenerateMatriz
Cell(1, 1) = Matriz(1, 1)
End Sub
A different approach would be to cast GenerateMatriz as a Function rather than a Sub
Function GenerateMatriz() As Variant
Dim SumaTotalCamiones, TotalClase, i As Integer
Dim Matriz() As Integer
i = 0
TotalClaseA = Worksheets("hoja1").Cells(4, 1).Value
TotalClaseB = Worksheets("hoja1").Cells(4 + 1, 1).Value
TotalClaseC = Worksheets("hoja1").Cells(4 + 2, 1).Value
SumaTotalCamiones = Worksheets("hoja1").Cells(4, 1).Value + Worksheets("hoja1").Cells(5, 1).Value + Worksheets("hoja1").Cells(6, 1).Value
ReDim Matriz(SumaTotalCamiones - 1, 3)
For j = 0 To TotalClaseA
n = 0
For n = 0 To 3
Matriz(i, n) = Worksheets("hoja3").Cells(i + 1, n + 1).Value
Next n
Next j
For j = TotalClaseA To TotalClaseA + TotalClaseB
n = 0
For n = 0 To 3
Matriz(i, n) = Worksheets("hoja3").Cells(i + 1, n + 1).Value
Next n
Next j
For j = TotalClaseA + TotalClaseB To TotalClaseA + TotalClaseB + TotalClaseC
n = 0
For n = 0 To 3
Matriz(i, n) = Worksheets("hoja3").Cells(i + 1, n + 1).Value
Next n
Next j
GenerateMatriz = Matriz
End Sub
And call that function from the other routine
Sub Test()
Dim myMatriz as Variant
myMatriz = GenerateMatriz()
Cell(1, 1) = myMatriz(1, 1)
End Sub