specify gap size using Randbetween function

White Top

New Member
Joined
May 1, 2019
Messages
2
How can RANDBETWEEN(1,850) be modified to select numbers <+8 or >-8 of the previous selection?
Thanks, White Top
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
[table="width:, class:grid"][tr][td="bgcolor:#c0c0c0"][/td][td="bgcolor:#c0c0c0"]
a​
[/td][td="bgcolor:#c0c0c0"]
b​
[/td][/tr][tr][td="bgcolor:#c0c0c0"]
2​
[/td][td]
254​
[/td][td]a2: =randbetween(1, 850)[/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
3​
[/td][td]
249​
[/td][td]a3: =randbetween(max(1, a2 - 8), min(a2 + 8, 850))[/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
4​
[/td][td]
249​
[/td][td][/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
5​
[/td][td]
253​
[/td][td][/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
6​
[/td][td]
252​
[/td][td][/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
7​
[/td][td]
252​
[/td][td][/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
8​
[/td][td]
260​
[/td][td][/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
9​
[/td][td]
266​
[/td][td][/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
10​
[/td][td]
266​
[/td][td][/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
11​
[/td][td]
271​
[/td][td][/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
12​
[/td][td]
272​
[/td][td][/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
13​
[/td][td]
268​
[/td][td][/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
14​
[/td][td]
273​
[/td][td][/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
15​
[/td][td]
271​
[/td][td][/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
16​
[/td][td]
267​
[/td][td][/td][/tr]
[tr][td="bgcolor:#c0c0c0"]
17​
[/td][td]
268​
[/td][td][/td][/tr]
[/table]
 
Upvote 0
[TABLE="class: grid"]
<tbody>[TR]
[TD="bgcolor: #c0c0c0"][/TD]
[TD="bgcolor: #c0c0c0"]
a​
[/TD]
[TD="bgcolor: #c0c0c0"]
b​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #c0c0c0"]
2​
[/TD]
[TD]
254​
[/TD]
[TD]a2: =randbetween(1, 850)[/TD]
[/TR]
[TR]
[TD="bgcolor: #c0c0c0"]
3​
[/TD]
[TD]
249​
[/TD]
[TD]a3: =randbetween(max(1, a2 - 8), min(a2 + 8, 850))[/TD]
[/TR]
[TR]
[TD="bgcolor: #c0c0c0"]
4​
[/TD]
[TD]
249​
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #c0c0c0"]
5​
[/TD]
[TD]
253​
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #c0c0c0"]
6​
[/TD]
[TD]
252​
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #c0c0c0"]
7​
[/TD]
[TD]
252​
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #c0c0c0"]
8​
[/TD]
[TD]
260​
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #c0c0c0"]
9​
[/TD]
[TD]
266​
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #c0c0c0"]
10​
[/TD]
[TD]
266​
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #c0c0c0"]
11​
[/TD]
[TD]
271​
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #c0c0c0"]
12​
[/TD]
[TD]
272​
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #c0c0c0"]
13​
[/TD]
[TD]
268​
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #c0c0c0"]
14​
[/TD]
[TD]
273​
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #c0c0c0"]
15​
[/TD]
[TD]
271​
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #c0c0c0"]
16​
[/TD]
[TD]
267​
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #c0c0c0"]
17​
[/TD]
[TD]
268​
[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Excellent! Thank you, works like a charm! One more very useful bit for my toolkit. Many thanks.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,847
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top