|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
花了一点时间编写,看看可行?
- Sub 随机分配五组3X5个不重数据()
- Dim arr(1 To 15), i, j, k, m, n, x
- '初始化数组(不重复15个数)
- For i = 1 To 15
- arr(i) = i
- Next
- '产生五组
- n = 7
- For m = 1 To 5
- '打乱顺序(洗牌)
- For i = 1 To 15
- j = Int(Rnd(1) * 100) Mod 15 + 1
- k = Int(Rnd * 15) + 1
- x = arr(j): arr(j) = arr(k): arr(k) = x
- Next i
-
- Cells(n, [I1].Column) = "第" & m & "组"
- '相应区域写入3X5不重复乱序数据
- For i = 1 To 5
- For j = 1 To 3
- Cells(n + i - 1, j + [I1].Column) = arr(j * i)
- Next j
- Next i
- n = n + 8
- Next m
- End Sub
复制代码
补充内容 (2023-4-3 20:00):
这段代码有误,10楼已订正.符合楼主要求的代码在13楼. |
|