Both mine and Vish's requirement are the same.
The requirement is to filter and sample a certain % of the number of visible records output by the filter.
I've broken the code into parts and i've tried to explain what i'm trying to accomplish with it:
The above part declares the variables required and i start with searching a column named DATA1 and include a new column at the end of the sheet after the last column and name it FLAG. Then i load the RAND() formula using FormulaR1C1.
In this part, the execution continues and in a for loop i set the autofilter field for that column DATA1 (which is the first column) and i execute it for all the 10 unique values in that column (limits of the for loop).
In the above part, i calculate the number of rows to be chosen as samples and store it in the variable called randRow. vCellCount contains the number of visible rows output by the filter set during each iteration of the for loop.
In this last part, using the .Resize line, i want to randomly mark the number of rows stored in randRow from the total rows available (stored in vCellCount). This line currently marks all the visible rows and that needs to be fixed
Hope this explanation suffices...
Sarang
Bookmarks