Hi All,
I'm having an issue with selecting a blank cell at random in a specified range. For some reason it is returning a cell that is out of the range given to the function or it is giving an error back. I have the following.
Set GSWS = Sheets("Game Sheet")
Set Anchor = GSWS.Range("B3")
Set GameZone = Anchor.Offset(1, 1).Resize(7, 7)
'Put in Specials
For n = 0 To 10
Do Until Application.WorksheetFunction.CountBlank(GameZone) = 0
Set Cel = RandCell(GameZone.SpecialCells(xlCellTypeBlanks))
If Cel = "" Then Exit Do
Loop
If Application.WorksheetFunction.CountBlank(GameZone) > 0 Then
GSWS.Range("L3").Offset(n).Copy Cel
Else
MsgBox "Grid is full"
End If
Nextn: Next n
End Sub
Function RandCell(Rg As Range) As Range
Set RandCell = Rg.Cells(Int(Rnd * Rg.Cells.Count) + 1)
End Function
Thanks in advance for any help!
Bookmarks