Excel related number

Hi all,
I have a doubt. I have one excel with different columns. Like Sl no, Date, Time etc. I have another excel with columns like Sl no, month etc. I have merge the Sl no column if 1st excel has 1 to 100 rows and when I am pasting 2nd excel the rows should start from 101 how to do this.
Please help me

Thank you in advance

Use merge datatable activity

image

Regards

@hanviprebday

Use the “Join Data Tables” activity to merge the data from dtExcel2 into dtExcel1 based on the “Sl no” column. Set the join type to “Full Outer Join” to include all rows from both DataTables.

For Each Row in mergedDataTable
If Not String.IsNullOrEmpty(Row(“month”).ToString.Trim) Then
Row(“Sl no”) = Convert.ToInt32(Row(“Sl no”)) + 100
End If

Use merge datatable activity

image
ignore error marks

Hope you understand
Usha

If I use merge data table in Sl no after 100 it’s coming again 1, 2 ,3 and so on but I want it to come as 101,102,103 etc and the rows will not always be 100 they may vary like some times we may have 50 rows also

Hi @hanviprebday

  • Read Range (Excel File 1) // Output: dtExcel1

  • Read Range (Excel File 2) // Output: dtExcel2

  • Assign lastRowNumber = dtExcel1.Rows.Count + 1

  • For Each Row (row in dtExcel2)

    • Assign row(“Sl no”) = lastRowNumber
    • Assign lastRowNumber = lastRowNumber + 1
  • Merge Data Table (Source: dtExcel2, Destination: dtExcel1)

  • Write Range (Excel File 1, dtExcel1)

Try to use append range

image

See this workflow-

Apply this after merging

https://forum.uipath.com/uploads/short-url/lxxgR8FsCxgugUWteGcBO5jDmRI.xaml

(From row In dt.AsEnumerable
Let indexValue=(dt.Rows.IndexOf(row)) + 1
Select dt.Clone.Rows.Add({indexValue,row(“Date”),row(“Time”)})).copytoDataTable

since your column slno is based on index, you can implement this after merging 2 datatables…

1 Like

Thank you all for helping me

Hey @hanviprebday, have you managed to resolve the issue? If so, kindly mark it as a solution to close the loop.
Thank you…

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