Write only specific row

Main.xaml (11.7 KB)

I read last row from an excel sheet. But when I want to write it in another excel sheet or workbook it writes whole sheet data. Could anyone please kindly say how can I write only last row data?

Call the specific row which you want to write on another workbook and before that use build data-table, it will work.

Dear @Sabbir_Anwar

Initialize a new datatable

dataTableFlt = New System.Data.DataTable()

Copy the filtered datatable (In case of data row convert into datatable) to dataTableFlt Datatable and write dataTableFlt to the excel



Hi @Sabbir_Anwar ,
Could you let us know why are using the Excel Application Scope Activity ? Do you have a Specific reason ?

Although it is perfectly fine to use the Excel activities, we firstly go for Workbook related activities for performing tasks related to reading/Writing of data to Excel files.

In your case, the last row data is not written to another sheet of your choice. We would have to use the Excel Append Range Activity and specify the desired sheet name to append the data to.
Since, the data type is DataRow, we would require to convert to Datatable in the below way and use it as the value to write :


The modified workflow would look as below :

Also, In your workflow, there are duplicate variables present. Do correct or remove the unwanted variables. Navigate to each of the Sequences present and remove the variables not required.

Check the modified workflow below :
There are two approaches, One using the Excel Activities Approach and other using Workbook activities.
Main1.xaml (13.7 KB)

To Test the other approach switch the Start to the Other Sequence.
Note: The Append Range activity is used considering that you would want to write to an existing filled sheet.

@supermanPunch Thank you so much . It works.

The reason, i used excel application scope, because when i used workbook activities then UiPath says “Read Range Workbook: Object reference not set to an instance of an object”.

1 Like

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