|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
多个工作簿,格式相同,在L列生成满足K列条件随机数(工作簿与工作簿生成的随机数不重复),找了一些方案,在实际操作中发现第一次与第二次生成的随机数会一模一样,求各路大神指点迷津
Sub 指定区间随机值批量填入指定多个工作簿()
Dim myPath, myFile, t As Double
myPath = ThisWorkbook.Path & "\"
myFile = Dir(myPath & "\*.xlsx")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Do While myFile > ""
Workbooks.Open myPath & myFile
Set sht = ActiveWorkbook.Sheets("FU Radio Test")
With sht
愚公移山,赋值这段省略了很多....
t = Int(6 * Rnd + 82) + Rnd
.Range("L26").Value = Round(t, 2)
t = Int((6 * Rnd) + 16) + Rnd
.Range("L64").Value = Round(t, 2)
t = Int((11 * Rnd) + 32) + Rnd
.Range("L65").Value = Round(t, 2)
t = Int((12 * Rnd) + 36) + Rnd
.Range("L66").Value = Round(t, 2)
t = Int((15 * Rnd) + 12) + Rnd
.Range("L67").Value = Round(t, 2)
t = Int((13 * Rnd) + 21) + Rnd
.Range("L68").Value = Round(t, 2)
t = Int((15 * Rnd) + 12) + Rnd
.Range("L69").Value = Round(t, 2)
t = Int((11 * Rnd) + 85) + Rnd
.Range("L74").Value = "-" & Round(t, 2)
t = Int((11 * Rnd) + 85) + Rnd
.Range("L75").Value = "-" & Round(t, 2)
End With
ActiveWorkbook.Save
ActiveWorkbook.Close
myFile = Dir
Loop
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
补充内容 (2023-4-27 22:50):
控制随机数不重复 |
-
-
新建文件夹.rar
110.55 KB, 下载次数: 4
多个工作簿,格式相同,在L列生成满足K列条件随机数(工作簿与工作簿生成的随机数不重复)
|