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
 

Some videos you may like

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,779
Office Version
  1. 2010
Platform
  1. Windows
a​
b​
2​
254​
a2: =randbetween(1, 850)
3​
249​
a3: =randbetween(max(1, a2 - 8), min(a2 + 8, 850))
4​
249​
5​
253​
6​
252​
7​
252​
8​
260​
9​
266​
10​
266​
11​
271​
12​
272​
13​
268​
14​
273​
15​
271​
16​
267​
17​
268​
 

White Top

New Member
Joined
May 1, 2019
Messages
2
a​
b​
2​
254​
a2: =randbetween(1, 850)
3​
249​
a3: =randbetween(max(1, a2 - 8), min(a2 + 8, 850))
4​
249​
5​
253​
6​
252​
7​
252​
8​
260​
9​
266​
10​
266​
11​
271​
12​
272​
13​
268​
14​
273​
15​
271​
16​
267​
17​
268​

<tbody>
</tbody>
Excellent! Thank you, works like a charm! One more very useful bit for my toolkit. Many thanks.
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,779
Office Version
  1. 2010
Platform
  1. Windows
You're welcome.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,158
Messages
5,594,588
Members
413,915
Latest member
namreh

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
Top