从一个起始的 ActiveCell 开始,如何随机生成周围的单元格并进一步从特定值随机生成
From a starting ActiveCell, how to randomly generate surrounding cells and further randomly generate from a specific value
我正在尝试让单元格在视觉上代表一组随机数字,这些数字能够基于 while 循环向外扩展(让我们从小处着手,只是将其设为 5x5 网格,我可以根据需要进行更新) .
示例:如果我的中心活动单元格是一个数字 =randbetween(1,10),其中 1-9 的答案会在它周围的相邻单元格中放置更多 1-10 的随机数。但是,如果值为 "10" 我希望此单元格周围 尚未 被填充的单元格旁边有公式是 =randbetween(11,20)。如果不覆盖所有内容并且只是一组数字,我似乎无法弄清楚如何做到这一点。
这个答案也可以用于非随机使用(例如,如果有人想展示如果 space 中有一把椅子,那么他们知道 table 或垃圾桶等将在它旁边的 space 中)
感谢您查看我的问题!
完成后应该是这样的:
在研究了一段时间之后,我想我会分享最终对我有用的东西作为赎罪:
Dim k As Single 'Total Move Count
Dim x As Single 'Starting point of spiral
Dim bool As Boolean 'Boolean for direction change
bool = True 'starts boolean as true
k = 1 'starts count at 1
x = 0 ' starts position as 0
Dim i As Single
i = 1
Dim j As Single
j = 1
Do While x <= 10
For n = 0 To k
If bool = True Then
ActiveCell.Value = "=randbetween(0,100)"
ActiveCell.Offset(0, 1).Select 'Move Right
i = i + 1
Else
ActiveCell.Value = "=randbetween(100,200)"
ActiveCell.Offset(0, -1).Select 'Move Left
i = i - 1
End If
Next n
For n = 0 To k
If bool = True Then
ActiveCell.Value = "=randbetween(200,300)"
ActiveCell.Offset(1, 0).Select 'Down
i = i + 1
ActiveCell.Value = "=randbetween(300,400)"
ActiveCell.Offset(-1, 0).Select 'Up
i = i - 1
End If
Next n
k = k + 1
bool = Not bool
'MsgBox bool
x = x + 1
Loop
我希望这对其他人有帮助!
我正在尝试让单元格在视觉上代表一组随机数字,这些数字能够基于 while 循环向外扩展(让我们从小处着手,只是将其设为 5x5 网格,我可以根据需要进行更新) .
示例:如果我的中心活动单元格是一个数字 =randbetween(1,10),其中 1-9 的答案会在它周围的相邻单元格中放置更多 1-10 的随机数。但是,如果值为 "10" 我希望此单元格周围 尚未 被填充的单元格旁边有公式是 =randbetween(11,20)。如果不覆盖所有内容并且只是一组数字,我似乎无法弄清楚如何做到这一点。
这个答案也可以用于非随机使用(例如,如果有人想展示如果 space 中有一把椅子,那么他们知道 table 或垃圾桶等将在它旁边的 space 中)
感谢您查看我的问题!
完成后应该是这样的:
在研究了一段时间之后,我想我会分享最终对我有用的东西作为赎罪:
Dim k As Single 'Total Move Count
Dim x As Single 'Starting point of spiral
Dim bool As Boolean 'Boolean for direction change
bool = True 'starts boolean as true
k = 1 'starts count at 1
x = 0 ' starts position as 0
Dim i As Single
i = 1
Dim j As Single
j = 1
Do While x <= 10
For n = 0 To k
If bool = True Then
ActiveCell.Value = "=randbetween(0,100)"
ActiveCell.Offset(0, 1).Select 'Move Right
i = i + 1
Else
ActiveCell.Value = "=randbetween(100,200)"
ActiveCell.Offset(0, -1).Select 'Move Left
i = i - 1
End If
Next n
For n = 0 To k
If bool = True Then
ActiveCell.Value = "=randbetween(200,300)"
ActiveCell.Offset(1, 0).Select 'Down
i = i + 1
ActiveCell.Value = "=randbetween(300,400)"
ActiveCell.Offset(-1, 0).Select 'Up
i = i - 1
End If
Next n
k = k + 1
bool = Not bool
'MsgBox bool
x = x + 1
Loop
我希望这对其他人有帮助!