excel VBA 如何在数组中每个数值都乘以20?
发布网友
发布时间:2022-05-13 08:04
我来回答
共1个回答
热心网友
时间:2024-02-21 18:57
两个例子,为了说的清楚,分别说明下,方法肯定不只这两种,请参考
Sub aaa()
'数组(arr1)里面 每个值都乘以20.然后再减去100
Dim arr, x
arr = Range("a1:a10")
For x = 1 To UBound(arr)
Dim arr1(1 To 10, 1 To 1)
k = k + 1
arr1(k, 1) = arr(x, 1) * 20 - 100
Next x
Stop
End Sub
Sub afd() '查数组的值大于4的个数
Dim arr, x, k
arr = Split("1\2\3\4\5", "\")
For x = 1 To UBound(arr)
Cells(x, 2) = arr(x)
Next x
MsgBox Application.CountIf(Range("b:b"), ">4")
End Sub