How to select random rows from an excel file and copy over to another excel file

Hi,

I am trying to select random rows from an excel document (e.g. 100 rows i need 30 random rows) and copy it over to another excel file. Currently i am trying AsEmunerable but it only gives me the first 30 rows.

Is there anything wrong with this or is there any alternative solutions.

@Needhelp
As an alternate you can create a list of Index numbers like this

With the distinct we do run till we got 30 unique index values.

The rows can be selected with: RandomList.Select(Function (x) DataTableVar.Rows(x)).CopytoDataTable

1 Like

HI,

Do you have the workflow?

Thanks alot for the help!

@Needhelp
Find starter help for generating the random Index numbers here:
Needhelp.xaml (6.0 KB)

@Needhelp

Give this a try:

PickRandomRows.zip (29.7 KB)