SkywardPalm
Board Regular
- Joined
- Oct 23, 2021
- Messages
- 61
- Office Version
- 365
- Platform
- Windows
I am attempting to populate random quality assurance checks into a Criteria column, if there are less cells populated with a Criteria (High Cost, High QTY) than the required (say 10%) quality check, then a "RANDOM" will be the cell's value. I can't wrap my mind around how to accomplish a legitimate random process that will populate based on the proper percentage (actively, on worksheet change). The percentage is set upon file creation in Range("Percent"). (It would also be nice if it didn't choose the first cell for a random on every instance if criteria is missing from first entry)
Column "AG" is where the criteria should populate. I multiply by 100 because the percentage is stored as a decimal.
Column "AG" is where the criteria should populate. I multiply by 100 because the percentage is stored as a decimal.
VBA Code:
'add a RANDOM after calculating if cells with criteria/value are < percent of quality checks
If IsEmpty(Range("AG" & ActiveCell.Row)) And Application.WorksheetFunction.CountA(Range("AG2:AG" & ActiveCell.Row)) < (Range("Percent") * ActiveCell.Row * 100) Then Range("AG" & ActiveCell.Row).Value = "RANDOM"