Try such code.
I probably don't have to say this, but … just for those not into statistics: Selecting 5% of random cells don't mean they will be evenly distributed in the range - there could be sometimes clusters of few cells (most often - two of course) next to each other and sometimes quite large regions without even single cell highlighted.
If one wants to not allow such clusters, an easy way would be (but then column A and row 1 cannot be included in the selected range) using so called hard core approach - as in the below line
instead of
Of course, in the code above you can use other means of defining the range where highlighting is to be done, like always Range("A1:X100") etc., not just selecting range before running the procedure.
Bookmarks