Random cell selection
Solved
DeepGap
Posted messages
2
Status
Member
-
DeepGap Posted messages 2 Status Member -
DeepGap Posted messages 2 Status Member -
Hello,
in a range of 9 cells of type range("a1:c3"), I would like to randomly select a cell using a VBA procedure.
My searches on forums have been unsuccessful.
Thank you in advance for your help.
in a range of 9 cells of type range("a1:c3"), I would like to randomly select a cell using a VBA procedure.
My searches on forums have been unsuccessful.
Thank you in advance for your help.
1 answer
-
Hello,
Sub CellAlea() Dim AleaRow As Integer Dim AleaCol As Integer Randomize Timer AleaRow = Int(Rnd() * 3) + 1 AleaCol = Int(Rnd() * 3) + 1 Cells(AleaRow, AleaCol).Select End Sub
--
"What is well conceived is clearly stated, and the words to say it come easily."
Nicolas Boileau-
Thank you Polux31 for this quick response that works
I finally found a solution on my side, without upsetting anyone, because even if I ask for help, I don't give up on "the matter".
So here it is
Cells(Int(Rnd * 3) + 8, Int(Rnd * 3) + 8).Select
It allows selecting in the range h8:j10 which was my target originally
I would have of course adapted your response Pollux31
I started from the following code that I found online
Cells(Int(Rnd * 10) + 1, 1).Select
I tested it to understand how it worked and then I found the solution above.
Thanks again
Best regards
-