JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,687
- Office Version
- 365
- Platform
- Windows
Given a list of numbers, I need some VBA code to select a random element from those associated with the minimum tally. For example, in this list I would like to select one of the 7's (highlighted in yellow) and return the associated Item (A, D, or F).
I can think of several solutions that involve looping. For example,
Random Minimum Value.xlsx | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
C | D | E | F | G | H | I | J | |||
5 | Tally | 7 | 9 | 8 | 7 | 10 | 7 | 8 | ||
6 | Item | A | B | C | D | E | F | G | ||
Sheet1 |
I can think of several solutions that involve looping. For example,
- Find the minimum value.
- Count how many there are (N).
- Generate a random integer (k) on (1,N).
- Select the item associated with the kth minimum value.