I'm trying to insert values into an excel table with the help of an array, it happens that when the program executes only the first value of the array is inserted in each specified range, how can I change this?
VBA Code:
Private Sub FillCells()
Dim myarray_ac_before As Variant, marray_ac_after As Variant, marray_sphere_before As Variant, marray_sphere_after As Variant, marray_compensation_before As Variant, marray_compensation_after As Variant
marray_ac_before = Array(MachineName, N_OT, Tec, Date_Today, hour, A_Grid_Orig, C_Grid_Orig, A2, A4, Xrel_90)
marray_ac_after = Array(A_Grid_Orig_D, C_Grid_Orig_D, A2_D, A4_D, Xrel_90_D)
marray_sphere_before = Array(P666, P709, P710, P713, A0, A_90, A90, Delta_A)
marray_sphere_after = Array(P666r, P709r, P710r, P713r, A0r, A_90r, A90r, Delta)
marray_compensation_before = Array(C0_A, C315_A, C270_A, C225_A, C180_A, C135_A, C90_A, C45_A, InitialSpread)
marray_compensation_after = Array(C0, C315, C270, C225, C180, C135, C90, C45, FinalSpread)
marray_spread = Array(InitialSpread, FinalSpread, Runnout)
Workbooks("Corrections_Data.xlsm").Sheets("AC_Offset_Registers").Activate
k_machine = Cells(Rows.Count, 2).End(xlUp).Offset(1).Row
Range(Cells(k_machine, 2), Cells(k_machine, 11)) = Application.Transpose(marray_ac_before)
Range(Cells(k_machine, 13), Cells(k_machine, 17)) = Application.Transpose(marray_ac_after)
Range(Cells(k_machine, 19), Cells(k_machine, 26)) = Application.Transpose(marray_sphere_before)
Range(Cells(k_machine, 28), Cells(k_machine, 35)) = Application.Transpose(marray_sphere_after)
Range(Cells(k_machine, 37), Cells(k_machine, 45)) = Application.Transpose(marray_compensation_before)
Range(Cells(k_machine, 47), Cells(k_machine, 55)) = Application.Transpose(marray_compensation_after)
Range(Cells(k_machine, 57), Cells(k_machine, 59)) = Application.Transpose(marray_spread)
Application.Run "Corrections_Data.xlsm! Text_In_Cells_Offset", k_machine
End Sub