Hi,
I have spreadsheet with long list import every month columns "E" = subtotal "F" = GST, "G" = QST , "H"= HST and fifth column "J" total
how can I modify the code below to add those columns above and put the total in column "J",
here is the code:
Sub SumByArray()
Dim arrayColA As Variant, arrayColB As Variant, arrayColC As Variant 'must be declared as variants.
Dim iArrayIndex As Long, dblArrayItemColA As Double, dblArrayItemColB As Double, dblArrayItemColC As Double
arrayColA = Sheet1.Range("E2:E1000")
arrayColB = Sheet1.Range("F2:F1000")
arrayColC = Sheet1.Range("J2:J1000")
For iArrayIndex = 1 To 10
dblArrayItemColA = arrayColA(iArrayIndex, 1)
dblArrayItemColB = arrayColB(iArrayIndex, 1)
dblArrayItemColJ = dblArrayItemColA + dblArrayItemColB
arrayColC(iArrayIndex, 1) = dblArrayItemColC
Next iArrayIndex
Sheet1.Range("J2:J1000") = arrayColC
End Sub
I tried but doesn't work just put "0" values in column "J"
than you,
Hi Jose,
Why are you using VBA for this? Just use a formula in Column J?
If you are using Power Query to import the data every month, use that to perform the calculation then write the data out to your worksheet.
Regards
Phil