Copy Excel cells to clipboard iteratively

Greetings,

I have been assigned a task to copy the first 10 cell values of an excel column using UiPath to clipboard. After copying that, I have to copy the next 10 cells of the first column and so on.
I tried to read it and capture it into an array but got error, Is there any way I can get this done?
For example,
image
In the above sheet I have to capture first 10 numbers, then next 10 and so on.
Please help me out on this one.

Hi,

In general, we can use DataTable with ReadRange activity in this case. Is there any special reason to use clipboard?

Regards,

Hi @shreesh.bhardwaj_7

You can use the select range activity in for each loop after select range you can use the set to clipboard activity or Hotkey (Clt + C) which will copy it to clipboard. Use this in for each loop increase the counter by 10.

Hope this helps :slight_smile:

Yeah, I have to paste this data on an application to send the message and do it for every 10 numbers.

Thank you let me implement this.

HI,

How about the following?

Sample
Sample20241015-3.zip (10.8 KB)

We may be able to achieve it using ReadRange and String Manipuation, too. (It depends on the application)

Regards,

You can use a looping to read cell and set it to clipboard

Is the symbol “¥” similar to “$” or is it another operator?
Also, let me try with this method as well, thank you!

Wouldn’t that copy just one value to clipboard and by the time a new value is added, the previous one gets removed?

In my environment (Japanese lang), backslash is displayed as ¥ sign. So can you try to use backslash for it?

Regards,

From my understanding, yes, everytime you set to clipboard, the original value in clipboard will be replaced.

If you would like to amend it, you can use one more variable to store previous value

Oh, thanks, let me try with this method.

numberBatches = dt.AsEnumerable().
Select(Function(row, index) New With {Value = row(“Number”).ToString(), index}).
GroupBy(Function(x) x.index \ batchSize).
Select(Function(g) g.Select(Function(x) x.Value).ToList()).
ToList()

This will create a list of batches. You can loop through the lists and use Set to Clipboard to copy it to the clipboard. P.S: batchSize=10

Hi,

Sorry, but there are some problem in the above sample. Can you try the following?

Sample
Sample20241015-3 (2).zip (10.9 KB)

Regards,

Sure, thanks.
Let me try with this one.

It’s working but, it’s capturing the data of both the columns, I just want to capture the numbers, can you tell me how to accomplish that?
Thank you!

Hi,

Can you try to replace “B” with “A” as the following in the 2 expressions?

 Excel.Sheet("Sheet1").Range("A"+(CurrentItem*chunkSize+2).ToString+":A"+((Currentitem+1)*chunkSize+1).ToString)

image

Regards,

Thank you so much!
It works like a charm!

1 Like

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