2017-09-30 回答
'我给你提供一个更好用的!
'选取你想要填充随机数的区域,然后运行宏“开始填充不重复随机整数”即可
'该宏不管你的区域是行,或是列,或是不连续,或是多列,多行
'不管什么样的区域,只要你选得出,都能运行并填写随机!
'而且随机是重复的整数,方便你后续处理
'想用更多填充功能或工具,包括重复或不重复的,请访问我的百度空间!
sub 开始填充不重复随机整数()
on error goto err
dim s as string
s = inputbox("请输入起始范围,格式如:“60-100”(不带引号)", "确定范围", "1-" & selection.cells.count)
if s = "" then exit sub
'sheet1.[保存上一次值].value = s
activesheet.enablecalculation = false
dim d as variant
d = split(s, "-")
dim p1 as long, p2 as long
p1 = val(d(0)): p2 = val(d(1))
dim s1 as string, i2 as long
for i2 = p1 to p2
s1 = s1 & i2 & ","
next