Another way
Option Explicit
Sub Test_1()
Dim rColor As Range
Dim i As Long, j As Long, numToBeFilled As Long, numFilled As Long
Dim aryRandom() As Double
Set rColor = Range("e2:i36")
numToBeFilled = 50
With rColor
.Interior.ColorIndex = xlColorIndexNone
'hold random number and index into Range
'use (0) to hold for swap in sort
ReDim aryRandom(0 To .Cells.Count, 1 To 2)
Randomize
For i = 1 To .Cells.Count
If Len(.Cells(i)) = 0 Then
aryRandom(i, 1) = Rnd ' random for sort
aryRandom(i, 2) = i ' Cells number
Else
aryRandom(i, 1) = 1# ' to push to bottom after sort
aryRandom(i, 2) = i
End If
Next i
'simple bubble sort pushed text cells to bottom
For i = 1 To .Cells.Count - 1
For j = i + 1 To .Cells.Count
If aryRandom(i, 1) > aryRandom(j, 1) Then
aryRandom(0, 1) = aryRandom(i, 1)
aryRandom(0, 2) = aryRandom(i, 2)
aryRandom(i, 1) = aryRandom(j, 1)
aryRandom(i, 2) = aryRandom(j, 2)
aryRandom(j, 1) = aryRandom(0, 1)
aryRandom(j, 2) = aryRandom(0, 2)
End If
Next j
Next i
numFilled = 0
i = 1
Do While (numFilled < numToBeFilled) And (aryRandom(i, 1) <> 1#)
.Cells(aryRandom(i, 2)).Interior.Color = vbRed
numFilled = numFilled + 1
i = i + 1
Loop
End With
End Sub