【问题标题】:Random number with VBAVBA 随机数
【发布时间】:2018-10-19 01:09:30
【问题描述】:

我正在尝试在给定范围内的随机概率的正态分布内创建随机数。我的代码如下:

Range(Cells(2, 1), Cells(RandomNumbers + 1, 1)) = WorksheetFunction.Norm_S_Inv(Rnd)

RandomNumbers 只是另一个单元格中的一个值。问题是如果RandomNumbers 等于10,那么VBA 在所有10 个单元格中填充相同的随机数。如何使每个单元格中的每个数字都不同?

【问题讨论】:

    标签: vba random


    【解决方案1】:

    让它成为一个循环:

    Dim cell as Range
    For Each cell In Range(Cells(2, 1), Cells(RandomNumbers + 1, 1))
        cell.Value = WorksheetFunction.Norm_S_Inv(Rnd)
    Next
    

    【讨论】:

      猜你喜欢
      • 2014-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-03
      • 2016-01-06
      • 2014-07-31
      • 2017-01-05
      • 2016-06-26
      相关资源
      最近更新 更多