Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

How to repeat a calculation n number of times inside one formula in Google Sheets (not arrays) for random number generation?

$
0
0

I'm trying to write a TTRPG-style calculator in Google Sheets for my own amusement to compare characters with different stat blocks. One of the things I want to have as an option is different "rounds", and allowing for characters to have different numbers of "rolls to hit" per round based on certain modifiers. Because of this, my number of 'hits per round' is variable.

To calculate whether a hit 'lands' or 'misses', I have a second variable, which is a percent value. To calculate if an individual hit 'lands', I'm using

=if((RANDBETWEEN(1,100)/100) < 'stat block'!E5, 1, 0)

(where 'stat block'!E5 is the percent of which hits land or miss).

I'd like to use a formula to automate repeating this, so that I can run this calculation n numbers of times and then sum it into one total of 'all hits per this one round'. I'm having trouble figuring out how to do so.

Specific constraint: I want to repeat this calculation with random numbers potentially up to 15 times in one sheet, so I'd rather not calculate a single value in a different array or something and then use that as the number of successful hits per round. I have a page that goes "round 1", "round 2", "round 3",... and I would like to calculate the number of hits per round for each round separately.

I have no experience with JavaScript and would prefer to avoid using custom functions.

Thank you so much, I appreciate any help.


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>