Hello,
I found this code searching online. The concept works; however, I am having trouble tweaking it to my needs. The code takes a random 10% of the information on sheet 1. What I would like it to do is to take random information from sheet 1 starting with line 9 instead of the whole sheet and have it pasted on Sheet 2 in the second line. Any assistance would be appreceiated.
Option Explicit
Sub Random10()
Randomize 'Initialize Random number seed
Dim MyRows() As Integer ' Declare dynamic array.
Dim numRows, percRows, nxtRow, nxtRnd, chkRnd, copyRow As Integer
'Determine Number of Rows in Sheet1 Column A
numRows = Sheets(1).Range("B" & Rows.Count).End(xlUp).Row
'Get 10% of that number
percRows = numRows * 0.1
'Allocate elements in Array
ReDim MyRows(percRows)
'Create Random numbers and fill array
For nxtRow = 1 To percRows
getNew:
'Generate Random number
nxtRnd = Int((numRows) * Rnd + 1)
'Loop through array, checking for Duplicates
For chkRnd = 1 To nxtRow
'Get new number if Duplicate is found
If MyRows(chkRnd) = nxtRnd Then GoTo getNew
Next
'Add element if Random number is unique
MyRows(nxtRow) = nxtRnd
Next
'Loop through Array, copying rows to Sheet2
For copyRow = 1 To percRows
Sheets(1).Rows(MyRows(copyRow)).EntireRow.Copy _
Destination:=Sheet2.Cells(copyRow, 1)
Next
End Sub
Bookmarks