Copy Specific Excel Data to Another Worksheet?

Hi all,

I have an excel sheet that is created once a week from a reporting system. It will always look like below screenshot (Headers start on cell B6 and the row count will be different each time. The columns will always be the same.).

What I need to do is grab only the information in the table, including the headers and copy it to another worksheet. The last row will always contain the “grand totals”. I do not need the title “Sales Reports” nor the “selection criteria” row. How would I get only the data and the headers?

Thanks!!

1 Like

Hi @Luecke_Anthony

In read range activity you can mention range. Give “B6” Range in read range and the excel data will be copied to a datatable. later you can write this datatable to any other sheet or workbook using write range activity.

Regards
Roshan

1 Like

But what if my row count is different each time, how would I tell it to grab the data all the way until the row with “Grand Totals”?

@Luecke_Anthony

The last row you don’t need to mention. mention only starting range. Also check the property first row is header.

Mark as solution if you found this helpful :slight_smile:

Regards
Roshan

Thank you, I tried this but when I write the output to excel, it includes the last row with “selection criteria” which I do not want. It is also not preserving the format of some columns even after clicking “preserve format”?

Hi @Luecke_Anthony ,

  • Use “Copy to WorkBook” activity from below.
  • find and replace activity from here.

Thank you
Balamurugan.S

1 Like

@Luecke_Anthony

Basically you need to remove last 2 rows of your datatable. use below code to do that
dt.AsEnumerable.Take(dt.Rows.Count -2).CopyToDataTable

If you get any error on asenumerable function. refere below link

Regards
Roshan

2 Likes

@balupad14 this activity set is great! Do you know how I could align a column left or right? I did not see this activity available for alignment. Thanks!

Hi @Luecke_Anthony,

The activity name is Format Cells

It has the features that are below it has all align features…

Thank you
Balamurugan.S

Share your workflow with sample excel. Let me check and get back to you…

Thank you
Balamurugan.S

@balupad14 Perfect, I didn’t realize this was in the Format Cells activity. Thanks!

1 Like

@balupad14 is this activity set compatible with 2019+ versions of Studio? It was working for me fine, but now seems to only work in debug mode, rather than normally in Studio? I’m on 2019.10.4 Thanks!

1 Like

yes . it is compatible…

1 Like

https://forum.uipath.com/t/cannot-display-the-colors-and-tables-in-the-original-file-after-they-are-run/227823?u=arifudinmyf

help me

@balupad14 If I’m using your “Change Cell Type” activity multiple times, should I include a long delay after each? I notice it’s only performing the activities in debug mode on slow step, but not when I actually run the process. No errors, the robot just stays running but does nothing.

It’s the same file path on each activity, and I have 11 of them total.

1 Like

can you share me the sample workflow ?

Hard to share because it works when I only have the “change cell type” activities…but when I have activities before it, it does not work, and the robot just freezes but shows no errors.

Create a sample and send me ?..

Thank you…

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