I want to move data from column A to column G of another file, how do I do that?

I want to move data from column A to column G of another file, how do I do that?
A->G
B->H
C->I



Best Regrads

@Famui_Yanisa

Use read range in range property “A:A” and store in datatable
Use Write range to write in range property “G:G” to a excel file

In write range in add headers mark as true

Hi @Famui_Yanisa

To move specific column values from one Excel file to the same column in another Excel file in UiPath, you can use the following steps:

  1. Read Data from the First Excel File:

    • Use the “Read Range workbook” activity to read the data from the first Excel file and store it in a DataTable variable (let’s call it dtSource).
  2. Extract the Specific Column:

    • Create a new DataTable (let’s call it dtSpecificColumn) with the same structure as the source DataTable, but only containing the specific column you want to move. You can use the “Build DataTable” activity to define the structure or filter the column using the “Filter Data Table” activity.
  3. Read Data from the Second Excel File:

    • Use the “Read Range workbook” activity inside the scope to read the data from the second Excel file and store it in another DataTable variable (let’s call it dtDestination).
  4. Merge the Specific Column:

    • Use a loop (e.g., For Each Row activity) to iterate through the rows of dtSpecificColumn.
    • For each row, update the corresponding row in dtDestination with the value from dtSpecificColumn for the specific column with “add data row” activity.
  5. Write Data to the Second Excel File:

    • Use the “Write Range workbook” activity to write the updated dtDestination DataTable back to the second Excel file.

Hope it helps!!

Hi @Famui_Yanisa

Have you tried vba yet?

Sub CopyData()
    Dim sourceWorkbook As Workbook
    Dim sourceSheet As Worksheet
    Dim lastRow As Long
    
    Set sourceWorkbook = ThisWorkbook
    Set sourceSheet = sourceWorkbook.Worksheets(1)
    lastRow = sourceSheet.Cells(sourceSheet.Rows.Count, "A").End(xlUp).Row


    Dim anotherWorkbook As Workbook
    Set anotherWorkbook = Workbooks.Open("C:\Users\Admin\Documents\AnotherBook1.xlsx")
   
    sourceSheet.Range("A2:A" & lastRow & "").Copy Destination:=ActiveSheet.Range("G2")
    sourceSheet.Range("B2:B" & lastRow & "").Copy Destination:=ActiveSheet.Range("H2")
    sourceSheet.Range("C2:C" & lastRow & "").Copy Destination:=ActiveSheet.Range("I2")
    
End Sub

Regards,
Tuan