您需要首先创建一个值数组。然后确保你在数组中循环。
Dim ArrayA As Variant
Dim ArrayB As Variant
Dim ArrayC() As Variant
ArrayA = Worksheets("Sheet1").Range("A1:A5").Value
ArrayB = Worksheets("Sheet1").Range("B1:B5").Value
'this is where things go bad
'ArrayC = ArrayA + 3 * ArrayB
'manually make array C the same size as array A
ReDim ArrayC(LBound(ArrayA, 1) To UBound(ArrayA, 1), 1 To 1)
Dim i As Long 'variable to count which section of the array we are on
' loop through each spot int he array and perform the math
For i = LBound(ArrayA, 1) To UBound(ArrayA, 1)
ArrayC(i, 1) = ArrayA(i, 1) + 3 * ArrayB(i, 1)
Next i
Worksheets("Sheet1").Range("C1:C5").Value = ArrayC
注意上面的代码未经测试,所以我可能在某处有错字。此外,在使用 redim 时,您可能需要声明 ArrayC 的数据类型而不是变量。我目前无法测试,因为我正在用手机接听电话。