|re: "I have code in Sheet 1"|
That's not what I asked.
I asked: "Do you have data in Sheet 1 Column A?" I am asking about the data in the spreadsheet, not about the macro.
The basic concept of the code is as follows:
1 - Determine how many rows of data are in Sheet 1 Column A, e.g. 100 rows.
2 - Calculate 20% of that number, e.g. 100 rows of data means that 20 rows will get copied.
3 - Randomly select e.g. 20 unique numbers between 1 and 100, inclusive, and store them in an array within VBA's memory.
4 - Loop through the array, copying the rows represented by the e.g. 20 random numbers from Sheet1 to Sheet 2.
I just entered data into Sheet1!A1:A100 and ran the code that you posted. It copied 20 unique, random rows from Sheet 1 to Sheet 2 as expected.
I then put data into Sheet1A1:A1000 and it copied 200 unique, random rows from Sheet 1 to Sheet 2.
Works just fine for me.
Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.