Help - how do I get a random value each time from Excel sheet

Hi all :slight_smile:

Pretty new to this and UiPath, so I apologise if this is a stupid question.

I have an excel sheet with a column of data ranging from X01 to X30 - I’m trying to get my robot to choose and copy a different cell every time I run my flow. However I have a little bit of a problem with that…

  1. How do I get Find Files and Folders to find my exact file? (not really sure I have figured out how that works yet)
  2. When I do that and use Read Cell, how do I then get it to be a different cell in that column each time?

Hoping some really smart people will help me here - as I said, a little new to this but I have been wrecking my brain with this for 2 days, so would really appreciate any help I can get.
Thank you so much!

Susanne :slightly_smiling_face: :upside_down_face:

Hey, here’s how u can get a random number under 30 using System.Random

@Sus-Mus

Find files have a query property which is used to give the name of the file you want…and sub folder is the folder path from base to the folder containing the file

And for random I believe @kali already has given yiu the way

Cheers

Hi @kali and @Anil_G :slightly_smiling_face:

Thank you so much - I think maybe I didn’t explain myself very well (my mistake - sorry)
I have a column (H-column) in an excel sheet. In that column I need the robot to pick a different cell each time - so first time H3, next time maybe H16 and so forth :sweat_smile:
Can you help me with that?

@Sus-Mus

Do you know what to pick?

If yes…then pass it in the variable and give it

"H" + variablewithcellnumber

Cheers

Hi @Sus-Mus

To learn - take a look at this post:

Save/copy these templates - replace capital letters with variables or string values (in quotes).
Step 1: Insert an Assign activity. The left assign will always be an “Array of String” System.String[ ]. Call it arr_Files.
Step 2: Use the below samples and insert on the Right Assign.

General template:
Directory.GetFiles(INSERTxFOLDERxPATH, INSERTxSEARCHxPATTERN)

Directory.GetFiles(INSERTxYOURxPATH, “*”)
This will return all files in the folders.

Directory.GetFiles(INSERTxYOURxPATH, “*.pdf”)
This will return all PDF files in the folders.

Directory.GetFiles(INSERTxYOURxPATH, “Report.xls*”)
This will return all Excel files with the word ‘Report’ in the filename within the folder. (Report123.xlsx or MyDailyReport456.xls)

Or you can use these XAMLs.

Get_File.xaml (11.5 KB)
Move_File.xaml (21.6 KB)

This should do the trick. To randomise the rows of a datatable give this a try:
Datatable_Randomise_Rows.xaml (14.8 KB)

You can also watch this video:
UiPath - How to Get FILES From DIRECTORY (youtube.com)

Hopefully this helps,

Cheers

Steve

1 Like

Hi all :slight_smile:
Sorry for the late reply - I cracked the problem thanks to you guys
Thank you so much

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.