How to copy a column with uncertain rows in Excel?

Dear Friends

I want to copy column C(without header) and past them in SAP

However, the rows in this file vary each time I download it from my system(10 rows at this time but next time may be 20 rows)

I need to figure out how to identify the last row of this column so that I can copy them accordingly

Thanks for your kind guidance in advance

image

Ivan

Read the excel as a workbook which would output as a datatable .
Datatable.Rows.Count.ToString should give you the total number of rows in the datatable.

or

dtVar.AsEnumerable().Select(Function(x) x(“YourColumnName”).ToString().Trim()).ToArray().Where(Function(y) Not String.IsNullOrEmpty(y)).ToArray().Count.ToString()

Thanks for the prompt reply, but I don’t know why it gives me 117 but not 11?

image

image

image

@yangyq10,

To copy anything into SAP in bulk, you should be copying the data into Clipboard with activity Activities - Set To Clipboard (uipath.com)

Thanks,
Ashok :slight_smile:

Datatable.Rows.Count.ToString should give you the total number of rows in the datatable. This gives the total number of rows in the DT
Try using this :
dtVar.AsEnumerable().Select(Function(x) x(“YourColumnName”).ToString().Trim()).ToArray().Where(Function(y) Not String.IsNullOrEmpty(y)).ToArray().Count.ToString()

Thank you for the follow up

There are other visible rows in the file which make it 117

Please mark it as a solution if it worked out

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