gpt4 book ai didi

excel - 如何在VBA中找到最小的数组,而不是在excel范围内

转载 作者:行者123 更新时间:2023-12-04 21:38:11 24 4
gpt4 key购买 nike

这里的基本思路是掷 4 d6,降到最低。

For lngPosition = LBound(strAttributes) To UBound(strAttributes)

i = 0
For shortPosition = LBound(intRoll) To UBound(intRoll)
intRoll(shortPosition) = Int((6 - 1 + 1) * Rnd + 1)
i = intRoll(shortPosition) + i
Next shortPosition

i = {i - smallest intRoll()}

strAttributes(lngPosition) = i

Next lngPosition

通过添加 .Small,我找到了很多关于如何在 excel 中找到一个范围内的最小值的信息。在定义范围之后,但我认为这在这里不起作用。可能是我在如何实现这一点上差了几英里,但我太新鲜了,我真的不知道。

谢谢

最佳答案

假设您的数组是一维数组,您仍然可以使用 worksheetfunction 类,例如:

Dim myArray
myArray = Array(5, 3, 103, 99, -14, 12)

Debug.Print Application.WorksheetFunction.Small(myArray, 1)

如果您的数组是多维的,那么您将需要使用蛮力迭代。

关于excel - 如何在VBA中找到最小的数组,而不是在excel范围内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28058075/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com