 <p>To take a random (pseudorandom, to be accurate) number, you can use <code>Rnd</code> function. It gives you a value in range form 0 to 1. To get some particular number from range, you can <a href="https://www.techonthenet.com/excel/formulas/rnd.php" rel="nofollow noreferrer">use this solution</a>. So, to get a random number from your range of row 2 to last , you can do for example:</p> <pre><code>Dim LastRow As Long, rRow As Long LastRow = Range("A" &amp; Rows.Count).End(xlUp).Row ' Last row based on column A rRow = Int((LastRow - 2 + 1) * Rnd + 2) </code></pre> <p>Now you need to take this 15 times, and be sure that you wont get the same row multiple times. We can use array, and store row numbers inside. Unfortunately, VBA has no function to check if some particular value is inside. We to do it by looping through the values. </p> <pre><code>Dim LastRow As Long, rRow As Long Dim rowArr(14) As Long Dim found As Boolean LastRow = Range("A" &amp; Rows.Count).End(xlUp).Row For i = 0 To 14 rRow = Int((LastRow - 2 + 1) * Rnd + 2) found = False If i &gt; 0 Then For j = i - 1 To 0 Step -1 If rowArr(j) = rRow Then found = True Next j End If If found Then i = i - 1 Else rowArr(i) = rRow End If Next i </code></pre> <p>No we have to check, if sum of values in random rows are equal to 12, and if not, loop the whole process. The whole thing will look like:</p> <pre><code>Dim LastRow As Long, rRow As Long Dim rowArr(14) As Long Dim found As Boolean, mainCriterium As Boolean Dim sumOfValues As Double mainCriterium = False Do While mainCriterium = False LastRow = Range("A" &amp; Rows.Count).End(xlUp).Row For i = 0 To 14 rRow = Int((LastRow - 2 + 1) * Rnd + 2) found = False If i &gt; 0 Then For j = i - 1 To 0 Step -1 If rowArr(j) = rRow Then found = True Next j End If If found Then i = i - 1 Else rowArr(i) = rRow End If Next i For i = 0 To 14 sumOfValues = sumOfValues + Range("G" &amp; rowArr(i)).Value Next i If sumOfValues = 12 Then mainCriterium = True Loop </code></pre> <p>When loop will end, you gonna have array <code>rowArr</code> containing 15 rows, which sum of values in column G is equal to 12.</p>