Hello All, I'm learning how to use arrays in excel vba. I would like to multiple cells is column A (100,000 cells from row 1 to 100,000) by cells in column B (100,000 cells from row 1 to 100,000) and put result into cells in column C. Something like this:
A1 * B1 = C1
A2 * B2 = C2
A3 * B2 = C3
...
A100000 * B100000 = C100000
I'm trying the following code:
Dim A() As Variant
Dim B() As Variant
Dim C(100000) As Variant
Dim i As Long
A() = Range("A1:A100000")
B() = Range("B1:B100000")
For i = LBound(A) To UBound(A)
C(i) = A(i, 1) * B(i, 1)
Next i
Range("C1:C100000").Value = C()
but it returns the result for A1*B1 operation for all 100k cells.
I've tried Application.Transpose(C), but it has limitation above 30+k of rows.
Could you please suggest what should I re-work in my code?
A1 * B1 = C1
A2 * B2 = C2
A3 * B2 = C3
...
A100000 * B100000 = C100000
I'm trying the following code:
Dim A() As Variant
Dim B() As Variant
Dim C(100000) As Variant
Dim i As Long
A() = Range("A1:A100000")
B() = Range("B1:B100000")
For i = LBound(A) To UBound(A)
C(i) = A(i, 1) * B(i, 1)
Next i
Range("C1:C100000").Value = C()
but it returns the result for A1*B1 operation for all 100k cells.
I've tried Application.Transpose(C), but it has limitation above 30+k of rows.
Could you please suggest what should I re-work in my code?